简体   繁体   中英

log4j.properties file to log4j2.xml conversion

I am upgrading from log4j1.x to log4j-2.8.2 I am trying to convert my existing log4j.properties file to equivalent log4j2.xml. My first question is can I write log4j2.proeprties file instead of log4j2.xml file?

I found some equivalent tags to log4j.proeprties file in log4j2.xml. I did not find tags for the below lines. can anybody suggest on this?

# LoggerFactory for ESAPI to utilize Log4J
log4j.loggerFactory=org.owasp.esapi.reference.Log4JLoggerFactory
log4j.category.Default=ALL, CONSOLE, RollingFile2, edelivery
log4j.rootCategory=OFF

log4j.logger.org.apache=INFO
log4j.logger.IntrusionDetector=ERROR
log4j.logger.org.springframework=WARN

Thanks in advance.

What i am sure is:
See the last three lines:

log4j.logger.org.apache=INFO
log4j.logger.IntrusionDetector=ERROR
log4j.logger.org.springframework=WARN

I think in log4j.xml they should be instead of like these below:

<Logger name="org.apache" level="INFO"/>
<Logger name="IntrusionDetector" level="ERROR"/>
<Logger name="org.springframework" level="WARN"/>

And what I am not sure is: these two lines:

log4j.category.Default=ALL, CONSOLE, RollingFile2, edelivery
log4j.rootCategory=OFF

I guess you have configured some appenders with the name in above line like:

<appender name="CONSOLE">
  other proerties....
</appender>

so i think you could try to use these in your log4j.xml:

<root>
  <appender-ref ref="ALL" />
  <appender-ref ref="CONSOLE" />
  <appender-ref ref="RollingFile2" />
  <appender-ref ref="edelivery" />
</root>  

And What I really don't know is:

log4j.loggerFactory=org.owasp.esapi.reference.Log4JLoggerFactory

I Know nothing about esapi so i could not suggest how to deal with it, hope someone else to give more answer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM