java 如何在 websphere 自由服务器中使用 log4j 配置日志记录?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25719288/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 08:32:20  来源:igfitidea点击:

How to configure the Logging using log4j in websphere liberty server?

javalog4jwebspherewebsphere-liberty

提问by user3860615

I tried to configure the logging in liberty profile but not getting the logs getting printed in my log file. I did the followings 1.In server.xml

我试图在自由配置文件中配置登录,但没有在我的日志文件中打印日志。我做了以下1.In server.xml

<logging maxFileSize="20" maxFiles="10" traceFileName="trace.log" traceSpecification="*com.ibm.ws.webcontainer*=all:com.ibm.wsspi.webcontiner*=all:com.ibm.ws.classloader.*=all:HTTPChannel=all:app.manager*=all:"/>
<logging consoleLogLevel="INFO" traceFormat="ADVANCED"/>

2.my log4j.property file

2.我的log4j.property文件

# Root logger option
log4j.rootLogger=DEBUG, stdout, file

# Redirect log messages to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

# Redirect log messages to a log file, support file rolling.
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=C://log4j-application.log
log4j.appender.file.MaxFileSize=5MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

Even after this I am not able to see any logs.

即使在此之后,我也看不到任何日志。

Please specify the log4j.properties file and the configurations need to get logging done in liberty server.

请指定 log4j.properties 文件和需要在 Liberty 服务器中完成日志记录的配置。

Thanks in advance

提前致谢

采纳答案by Gas

Liberty does not use Log4j for internal logging and tracing. You will find server log files in the LIBERTY_INSTALL\usr\servers\serverName\logsdirectory.

Liberty 不使用 Log4j 进行内部日志记录和跟踪。您将在该LIBERTY_INSTALL\usr\servers\serverName\logs目录中找到服务器日志文件。

For more information about logging see Liberty profile: Logging and Trace

有关日志记录的更多信息,请参阅Liberty 配置文件:日志记录和跟踪