Skip to content

Commit bf9fdad

Browse files
committed
Fix build errors due to log4j 2.x changes
1 parent 7b57480 commit bf9fdad

4 files changed

Lines changed: 8 additions & 11 deletions

File tree

engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41900to41910.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
// under the License.
1717
package com.cloud.upgrade.dao;
1818

19-
import org.apache.log4j.Logger;
20-
2119
import com.cloud.upgrade.SystemVmTemplateRegistration;
2220
import com.cloud.utils.exception.CloudRuntimeException;
2321

engine/schema/src/main/java/com/cloud/usage/dao/UsageVpcDaoImpl.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import com.cloud.utils.db.GenericDaoBase;
2323
import com.cloud.utils.db.SearchCriteria;
2424
import com.cloud.utils.db.TransactionLegacy;
25-
import org.apache.log4j.Logger;
2625
import org.springframework.stereotype.Component;
2726

2827
import java.sql.PreparedStatement;
@@ -34,7 +33,6 @@
3433

3534
@Component
3635
public class UsageVpcDaoImpl extends GenericDaoBase<UsageVpcVO, Long> implements UsageVpcDao {
37-
private static final Logger LOGGER = Logger.getLogger(UsageVpcDaoImpl.class);
3836
protected static final String GET_USAGE_RECORDS_BY_ACCOUNT = "SELECT id, vpc_id, zone_id, account_id, domain_id, state, created, removed FROM usage_vpc WHERE " +
3937
" account_id = ? AND ((removed IS NULL AND created <= ?) OR (created BETWEEN ? AND ?) OR (removed BETWEEN ? AND ?) " +
4038
" OR ((created <= ?) AND (removed >= ?)))";
@@ -52,7 +50,7 @@ public void update(UsageVpcVO usage) {
5250
update(vo.getId(), vo);
5351
}
5452
} catch (final Exception e) {
55-
LOGGER.error(String.format("Error updating usage of VPC due to [%s].", e.getMessage()), e);
53+
logger.error(String.format("Error updating usage of VPC due to [%s].", e.getMessage()), e);
5654
txn.rollback();
5755
} finally {
5856
txn.close();
@@ -74,7 +72,7 @@ public void remove(long vpcId, Date removed) {
7472
}
7573
} catch (final Exception e) {
7674
txn.rollback();
77-
LOGGER.error(String.format("Error updating usage of VPC due to [%s].", e.getMessage()), e);
75+
logger.error(String.format("Error updating usage of VPC due to [%s].", e.getMessage()), e);
7876
} finally {
7977
txn.close();
8078
}
@@ -121,7 +119,7 @@ public List<UsageVpcVO> getUsageRecords(Long accountId, Date startDate, Date end
121119
}
122120
} catch (Exception e) {
123121
txn.rollback();
124-
LOGGER.warn("Error getting VPC usage records", e);
122+
logger.warn("Error getting VPC usage records", e);
125123
} finally {
126124
txn.close();
127125
}

usage/src/main/java/com/cloud/usage/UsageManagerImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,7 @@ private boolean parseHelperTables(AccountVO account, Date currentStartDate, Date
10451045
}
10461046
parsed = VpcUsageParser.parse(account, currentStartDate, currentEndDate);
10471047
if (!parsed) {
1048-
s_logger.debug(String.format("VPC usage failed to parse for account [%s].", account));
1048+
logger.debug(String.format("VPC usage failed to parse for account [%s].", account));
10491049
}
10501050
return parsed;
10511051
}
@@ -2140,7 +2140,7 @@ private void handleVpcEvent(UsageEventVO event) {
21402140
UsageVpcVO usageVPCVO = new UsageVpcVO(event.getResourceId(), event.getZoneId(), event.getAccountId(), domainId, Vpc.State.Enabled.name(), event.getCreateDate(), null);
21412141
usageVpcDao.persist(usageVPCVO);
21422142
} else {
2143-
s_logger.error(String.format("Unknown event type [%s] in VPC event parser. Skipping it.", event.getType()));
2143+
logger.error(String.format("Unknown event type [%s] in VPC event parser. Skipping it.", event.getType()));
21442144
}
21452145
}
21462146

usage/src/main/java/com/cloud/usage/parser/VpcUsageParser.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,17 @@
2424
import javax.annotation.PostConstruct;
2525
import javax.inject.Inject;
2626
import org.apache.cloudstack.usage.UsageTypes;
27+
import org.apache.logging.log4j.Logger;
28+
import org.apache.logging.log4j.LogManager;
2729
import org.springframework.stereotype.Component;
2830

2931
import java.text.DecimalFormat;
3032
import java.util.Date;
3133
import java.util.List;
32-
import org.apache.log4j.Logger;
3334

3435
@Component
3536
public class VpcUsageParser {
36-
private static final Logger LOGGER = Logger.getLogger(VpcUsageParser.class.getName());
37+
private static final Logger LOGGER = LogManager.getLogger(VpcUsageParser.class.getName());
3738

3839
@Inject
3940
private UsageVpcDao vpcDao;

0 commit comments

Comments
 (0)