AmanDaharwal commented on issue #2185:
URL: 
https://github.com/apache/logging-log4j2/issues/2185#issuecomment-1891357778

   @vy Previously we were using log4j 1.x references for logging 
(org.apache.log4j ) and log4j 2.x dependency (Log 4j 2.22.0). We were using 
below code to make it compatible
   ```
   private static void setLog4jCompatibility() {
           // Migrating from Log4j 1.x to 2.x - 
https://logging.apache.org/log4j/2.x/manual/migration.html
           System.setProperty("log4j1.compatibility", "true");
       }
   ```
   
   Now, we updated our log4j 1.x references with log4j 2.x ( 
org.apache.logging.log4j) with same log4j 2.x dependency (Log 4j 2.22.0). Also 
remove the above compatibility code.
   
   With old log4j.properties files( mentioned below), we are not getting logs 
on CONSOLE, though they getting logged properly in file 
   
   ```
   # root logger
   log4j.rootLogger=INFO,CONSOLE,R
   # appender
   log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
   log4j.appender.R=org.apache.log4j.RollingFileAppender
   #log file location
   log4j.appender.R.File=${LOG_DIR}/testLogs/teswizSampleTestLog.log
   # layout and pattern
   log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
   log4j.appender.CONSOLE.layout.ConversionPattern=%5p [%t] (%F:%L)- %m%n
   log4j.appender.R.layout=org.apache.log4j.PatternLayout
   log4j.appender.R.layout.ConversionPattern=%d - %c -%p - %m%n
   log4j.appender.R.Append=false
   ```
   
   Also, tried updating to log4j2.properties file, but no logs are getting 
logged at CONSOLE or FILE.
   
   ```
   status = error
   dest = err
   name = PropertiesConfig
   
   property.filename = ${LOG_DIR}/testLogs/teswizSampleTestLog.log
   
   
   appenders = console, rolling
   appender.console.type = Console
   appender.console.name = STDOUT
   appender.console.layout.type = PatternLayout
   appender.console.layout.pattern = [%d{yyyy-MM-dd HH:mm:ss,SSS}] %-5p 
[%c.%M()] (%t) %m%n
   appender.rolling.type = RollingFile
   appender.rolling.name = RollingFile
   appender.rolling.fileName = ${LOG_DIR}/testLogs/teswizSampleTestLog.log
   appender.rolling.filePattern = $%d{MM-dd-yy-HH-mm-ss}
   appender.rolling.layout.type = PatternLayout
   appender.rolling.layout.pattern = [%d{yyyy-MM-dd HH:mm:ss,SSS}] %-5p 
[%c.%M()] (%t) %m%n
   appender.rolling.policies.type = Policies
   appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
   appender.rolling.policies.time.interval = 2
   appender.rolling.policies.time.modulate = true
   appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
   appender.rolling.policies.size.size=100MB
   appender.rolling.strategy.type = DefaultRolloverStrategy
   appender.rolling.strategy.max = 5
   
   
   rootLogger.level = info
   rootLogger.appenderRefs = console, rolling
   rootLogger.appenderRef.console.ref = STDOUT
   rootLogger.appenderRef.rolling.ref = RollingFile
   
   # The root logger with appender name
   rootLogger = INFO, STDOUT
   ```
   
   Also, using the PropertyConfigurator to configure both files
   
   ```
   Path logFilePath = Paths.get(properties.get(LOG_PROPERTIES_FILE).toString());
   configs.put(LOG_PROPERTIES_FILE, logFilePath.toString());
   inputStream = Files.newInputStream(logFilePath);
   PropertyConfigurator.configure(inputStream);
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to