我正在Karaf 4.1.2中部署OSGi捆绑软件。
为了将程序输出记录在专用文件中,我在org.ops4j.pax.logging.cfg中添加了以下几行:
log4j2.logger.mylogger.name = com.mycompany
log4j2.logger.mylogger.level = INFO
log4j2.logger.mylogger.appenderRef.MyFileAppender.ref = MyFileAppender
log4j2.appender.myfileappender.name = MyFileAppender
log4j2.appender.myfileappender.type = DailyRollingFile
log4j2.appender.myfileappender.fileName = /path/to/my/log_file.log
log4j2.appender.myfileappender.filePattern = /path/to/my/log_file.log.%i
log4j2.appender.myfileappender.append = true
log4j2.appender.myfileappender.layout.type = PatternLayout
log4j2.appender.myfileappender.layout.pattern = %d{ISO8601} | %-5p | %X{bundle.name} | %m%n
然后用Java:
org.apache.log4j.Logger logger = org.apache.log4j.LogManager.getLogger("com.mycompany");
logger.info("I never thought logging could bring me to stackoverflow");
文件上没有任何内容。
我在哪部分弄错了?