Skip to content

Commit

Permalink
TRUNK-6057: log4j2.x changes in 2.1.x (#3979)
Browse files Browse the repository at this point in the history
  • Loading branch information
sivareddyp committed Jan 28, 2022
1 parent 2ddd5d8 commit 11e9a08
Show file tree
Hide file tree
Showing 248 changed files with 1,502 additions and 1,088 deletions.
20 changes: 12 additions & 8 deletions api/pom.xml
Expand Up @@ -51,10 +51,6 @@
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
Expand Down Expand Up @@ -164,16 +160,24 @@
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
Expand Down
6 changes: 3 additions & 3 deletions api/src/main/java/org/openmrs/Concept.java
Expand Up @@ -27,8 +27,8 @@
import java.util.stream.Collectors;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.hibernate.search.annotations.ContainedIn;
import org.hibernate.search.annotations.DocumentId;
Expand Down Expand Up @@ -75,7 +75,7 @@ public class Concept extends BaseOpenmrsObject implements Auditable, Retireable,

public static final long serialVersionUID = 57332L;

private static final Log log = LogFactory.getLog(Concept.class);
private static final Logger log = LoggerFactory.getLogger(Concept.class);

// Fields
@DocumentId
Expand Down
6 changes: 3 additions & 3 deletions api/src/main/java/org/openmrs/ConceptProposal.java
Expand Up @@ -9,8 +9,8 @@
*/
package org.openmrs;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.openmrs.util.OpenmrsConstants;

import java.util.Date;
Expand All @@ -26,7 +26,7 @@ public class ConceptProposal extends BaseOpenmrsObject {

public static final long serialVersionUID = 57344L;

private static final Log log = LogFactory.getLog(ConceptProposal.class);
private static final Logger log = LoggerFactory.getLogger(ConceptProposal.class);

// Fields

Expand Down
6 changes: 3 additions & 3 deletions api/src/main/java/org/openmrs/ConceptStateConversion.java
Expand Up @@ -9,8 +9,8 @@
*/
package org.openmrs;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* ConceptStateConversion
Expand All @@ -19,7 +19,7 @@ public class ConceptStateConversion extends BaseOpenmrsObject {

public static final long serialVersionUID = 3214511L;

protected final Log log = LogFactory.getLog(ConceptStateConversion.class);
protected final Logger log = LoggerFactory.getLogger(ConceptStateConversion.class);

// ******************
// Properties
Expand Down
6 changes: 3 additions & 3 deletions api/src/main/java/org/openmrs/Obs.java
Expand Up @@ -10,8 +10,8 @@
package org.openmrs;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.openmrs.annotation.AllowDirectAccess;
import org.openmrs.api.APIException;
import org.openmrs.api.context.Context;
Expand Down Expand Up @@ -104,7 +104,7 @@ public enum Status {

public static final long serialVersionUID = 112342333L;

private static final Log log = LogFactory.getLog(Obs.class);
private static final Logger log = LoggerFactory.getLogger(Obs.class);

private static final String FORM_NAMESPACE_PATH_SEPARATOR = "^";

Expand Down
6 changes: 3 additions & 3 deletions api/src/main/java/org/openmrs/ObsPostLoadEventListener.java
Expand Up @@ -13,8 +13,8 @@

import javax.annotation.PostConstruct;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.hibernate.SessionFactory;
import org.hibernate.event.service.spi.EventListenerRegistry;
import org.hibernate.event.spi.EventType;
Expand All @@ -39,7 +39,7 @@
@Component
public class ObsPostLoadEventListener implements PostLoadEventListener {

private static final Log log = LogFactory.getLog(ObsPostLoadEventListener.class);
private static final Logger log = LoggerFactory.getLogger(ObsPostLoadEventListener.class);

@Autowired
private SessionFactory sessionFactory;
Expand Down
6 changes: 3 additions & 3 deletions api/src/main/java/org/openmrs/PatientIdentifier.java
Expand Up @@ -9,8 +9,8 @@
*/
package org.openmrs;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.hibernate.search.annotations.Analyzer;
import org.hibernate.search.annotations.Boost;
Expand Down Expand Up @@ -39,7 +39,7 @@ public class PatientIdentifier extends BaseOpenmrsData implements java.io.Serial

public static final long serialVersionUID = 1123121L;

private static final Log log = LogFactory.getLog(PatientIdentifier.class);
private static final Logger log = LoggerFactory.getLogger(PatientIdentifier.class);

// Fields

Expand Down
8 changes: 4 additions & 4 deletions api/src/main/java/org/openmrs/Person.java
Expand Up @@ -9,8 +9,8 @@
*/
package org.openmrs;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.hibernate.search.annotations.ContainedIn;
import org.hibernate.search.annotations.DocumentId;
Expand Down Expand Up @@ -41,7 +41,7 @@ public class Person extends BaseOpenmrsData {

public static final long serialVersionUID = 2L;

protected final Log log = LogFactory.getLog(getClass());
protected final Logger log = LoggerFactory.getLogger(getClass());

@DocumentId
protected Integer personId;
Expand Down Expand Up @@ -259,7 +259,7 @@ public Date getBirthDateTime() {
try {
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(birthDateString + " " + birthTimeString);
} catch (ParseException e) {
log.error(e);
log.error("ParseException", e);
}
}
return null;
Expand Down
6 changes: 3 additions & 3 deletions api/src/main/java/org/openmrs/PersonAddress.java
Expand Up @@ -16,8 +16,8 @@

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.openmrs.util.OpenmrsUtil;

Expand All @@ -29,7 +29,7 @@ public class PersonAddress extends BaseOpenmrsData implements java.io.Serializab

public static final long serialVersionUID = 343333L;

private static final Log log = LogFactory.getLog(PersonAddress.class);
private static final Logger log = LoggerFactory.getLogger(PersonAddress.class);

// Fields

Expand Down
6 changes: 3 additions & 3 deletions api/src/main/java/org/openmrs/PersonAttribute.java
Expand Up @@ -10,8 +10,8 @@
package org.openmrs;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.hibernate.search.annotations.Analyzer;
import org.hibernate.search.annotations.Boost;
import org.hibernate.search.annotations.DocumentId;
Expand Down Expand Up @@ -45,7 +45,7 @@ public class PersonAttribute extends BaseOpenmrsData implements java.io.Serializ

public static final long serialVersionUID = 11231211232111L;

private static final Log log = LogFactory.getLog(PersonAttribute.class);
private static final Logger log = LoggerFactory.getLogger(PersonAttribute.class);

// Fields
@DocumentId
Expand Down
6 changes: 3 additions & 3 deletions api/src/main/java/org/openmrs/PersonName.java
Expand Up @@ -10,8 +10,8 @@
package org.openmrs;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.hibernate.search.annotations.Analyzer;
import org.hibernate.search.annotations.Boost;
Expand Down Expand Up @@ -40,7 +40,7 @@ public class PersonName extends BaseOpenmrsData implements java.io.Serializable,

public static final long serialVersionUID = 4353L;

private static final Log log = LogFactory.getLog(PersonName.class);
private static final Logger log = LoggerFactory.getLogger(PersonName.class);

// Fields
@DocumentId
Expand Down
6 changes: 3 additions & 3 deletions api/src/main/java/org/openmrs/Provider.java
Expand Up @@ -9,8 +9,8 @@
*/
package org.openmrs;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Represents a person who may provide care to a patient during an encounter
Expand All @@ -19,7 +19,7 @@
*/
public class Provider extends BaseCustomizableMetadata<ProviderAttribute> {

private final Log log = LogFactory.getLog(getClass());
protected final Logger log = LoggerFactory.getLogger(getClass());

private Integer providerId;

Expand Down
6 changes: 3 additions & 3 deletions api/src/main/java/org/openmrs/Role.java
Expand Up @@ -9,8 +9,8 @@
*/
package org.openmrs;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.openmrs.util.RoleConstants;

import java.util.Collection;
Expand All @@ -29,7 +29,7 @@ public class Role extends BaseOpenmrsMetadata {

public static final long serialVersionUID = 1234233L;

private static final Log log = LogFactory.getLog(Role.class);
private static final Logger log = LoggerFactory.getLogger(Role.class);

// Fields

Expand Down
6 changes: 3 additions & 3 deletions api/src/main/java/org/openmrs/User.java
Expand Up @@ -21,8 +21,8 @@
import java.util.Set;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.openmrs.api.context.Context;
import org.openmrs.util.LocaleUtility;
import org.openmrs.util.OpenmrsConstants;
Expand All @@ -40,7 +40,7 @@ public class User extends BaseOpenmrsMetadata implements java.io.Serializable, A

public static final long serialVersionUID = 2L;

protected final Log log = LogFactory.getLog(getClass());
protected final Logger log = LoggerFactory.getLogger(getClass());

// Fields

Expand Down
6 changes: 3 additions & 3 deletions api/src/main/java/org/openmrs/aop/AuthorizationAdvice.java
Expand Up @@ -13,8 +13,8 @@
import java.util.Collection;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.openmrs.User;
import org.openmrs.annotation.AuthorizedAnnotationAttributes;
import org.openmrs.api.APIAuthenticationException;
Expand All @@ -30,7 +30,7 @@ public class AuthorizationAdvice implements MethodBeforeAdvice {
/**
* Logger for this class and subclasses
*/
protected final Log log = LogFactory.getLog(AuthorizationAdvice.class);
protected final Logger log = LoggerFactory.getLogger(AuthorizationAdvice.class);

/**
* Allows us to check whether a user is authorized to access a particular method.
Expand Down
25 changes: 13 additions & 12 deletions api/src/main/java/org/openmrs/aop/LoggingAdvice.java
Expand Up @@ -9,18 +9,19 @@
*/
package org.openmrs.aop;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openmrs.User;
import org.openmrs.annotation.Logging;
import org.openmrs.api.context.Context;
import org.openmrs.util.OpenmrsConstants;
import org.openmrs.util.OpenmrsUtil;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* This class provides the log4j aop around advice for our service layer. This advice is placed on
Expand All @@ -29,18 +30,18 @@
*/
public class LoggingAdvice implements MethodInterceptor {

/**
* Logger for this class. Uses the name "org.openmrs.api" so that it seems to fit into the
* log4j.xml configuration
*/
protected static final Log log = LogFactory.getLog("org.openmrs.api");

/**
* List of all method name prefixes that result in INFO-level log messages
*/
private static final String[] SETTER_METHOD_PREFIXES = { "save", "create", "update", "void", "unvoid", "retire",
"unretire", "delete", "purge" };

/**
* Logger for this class. Uses the name "org.openmrs.api" so that it seems to fit into the
* log4j2.xml configuration
*/
private final Logger log = LoggerFactory.getLogger(OpenmrsConstants.LOG_CLASS_DEFAULT);

/**
* This method prints out debug statements for getters and info statements for everything else
* ("setters"). If debugging is turned on, execution time for each method is printed as well.
Expand Down
6 changes: 3 additions & 3 deletions api/src/main/java/org/openmrs/api/EventListeners.java
Expand Up @@ -11,15 +11,15 @@

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Holds all OpenMRS event listeners
*/
public class EventListeners {

private static Log log = LogFactory.getLog(EventListeners.class);
private static Logger log = LoggerFactory.getLogger(EventListeners.class);

private static List<GlobalPropertyListener> globalPropertyListeners = null;

Expand Down

0 comments on commit 11e9a08

Please sign in to comment.