开发者

Separate application log data from server log data using log4j

开发者 https://www.devze.com 2023-04-09 05:46 出处:网络
I am creating a java application which starts a server (Selenium server), performs some actions (run automation tests) and shuts down the server in the end. I am using log4j as the logging framework.

I am creating a java application which starts a server (Selenium server), performs some actions (run automation tests) and shuts down the server in the end. I am using log4j as the logging framework. The log that is generated contains log data which is sent by my application as well as that which is generated by the server. My log4j.properties is as shown -

log4j.rootCategory=info,R1,R2

log4j.appender.R2=org.apache.log4j.ConsoleAppender
log4j.appender.R2.layout=org.apache.log4j.PatternLayout
log4j.appender.R2.layout.ConversionPattern=[%d{MMM dd HH:mm:ss}] %-5p (%F:%L) - %m%n

log4j.category.com.xyz.abc.tests=info, R1

log4j.appender.R1.File=C:/my_log.log
log4j.appender.R1=org.apache.log4j.RollingFileAppender
开发者_StackOverflow社区log4j.appender.R1.layout=org.apache.log4j.PatternLayout
log4j.appender.R1.layout.ConversionPattern=[%d{MMM dd HH:mm:ss}] %-5p (%F:%L) - %m%n

My question is how do I separate the log data that is sent by my application from that which is generated by the server?


you should provide appender for that package/category :
log4j.category.<selenium-pkg>=<level>, <appender>
for example:
log4j.category.org.openqa.selenium=INFO, R2

0

精彩评论

暂无评论...
验证码 换一张
取 消