如何在mac系统中为tomcat服务器设置log4j日志文件

daolsyd0  于 2021-10-10  发布在  Java
关注(0)|答案(0)|浏览(294)

我最近从windows切换到mac系统。我使用eclipse设置了我的工作区,并安装了tomcat。在运行tomcat服务器时,控制台显示以下消息。

log4j: Class name: [org.apache.log4j.AsyncAppender]
log4j: Setting property [bufferSize] to [128].
log4j: Setting property [blocking] to [false].
log4j: Attaching appender named [TxnLogDbAppender] to appender named [AsyncTxnDB].
log4j: Class name: [com.garmin.gcs.services.pobt.log.appender.TxnDBAppender]
log4j: Setting property [levelMin] to [INFO].
log4j: Setting property [levelMax] to [INFO].
log4j: Adding filter of type [class org.apache.log4j.varia.LevelRangeFilter] to appender named [TxnLogDbAppender].
log4j: Adding appender named [AsyncTxnDB] to category [com.garmin.gcs.common.servlet.filter.transaction.UserContextFilter].
log4j: Adding appender named [ErrorFileAppender] to category [com.garmin.gcs.common.servlet.filter.transaction.UserContextFilter].
log4j: Retreiving an instance of org.apache.log4j.Logger.
log4j: Setting [com.garmin.gcs.common.servlet.filter.logging.URITransactionLoggingFilter] additivity to [false].
log4j: Level value for com.garmin.gcs.common.servlet.filter.logging.URITransactionLoggingFilter is  [INFO].
log4j: com.garmin.gcs.common.servlet.filter.logging.URITransactionLoggingFilter level set to INFO
log4j: Class name: [org.apache.log4j.DailyRollingFileAppender]
log4j: Setting property [file] to [/web/logs/gcs-partneronboardingtool/gcs-partneronboardingtool-txn.log].
log4j: Setting property [datePattern] to ['.'yyyy-MM-dd_HH].
log4j: Setting property [encoding] to [UTF-8].
log4j: Parsing layout of class: "org.apache.log4j.PatternLayout"
log4j: Setting property [conversionPattern] to [%n***LoggableTransaction***%n%m%n].
log4j: setFile called: /web/logs/gcs-partneronboardingtool/gcs-partneronboardingtool-txn.log, true
log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: /web/logs/gcs-partneronboardingtool/gcs-partneronboardingtool-txn.log (No such file or directory)
    at java.io.FileOutputStream.open0(Native Method)
    at java.io.FileOutputStream.open(FileOutputStream.java:270)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:133)
    at org.apache.log4j.FileAppender.setFile(FileAppender.java:290)
    at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:164)
    at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:216)
    at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:257)
    at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:285)
    at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:171)
    at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:184)
    at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:502)
    at org.apache.log4j.xml.DOMConfigurator.parseCategory(DOMConfigurator.java:415)
    at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:919)
    at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:790)
    at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:696)
    at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:471)
    at org.apache.log4j.LogManager.<clinit>(LogManager.java:125)
    at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:66)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:277)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:288)
    at org.activiti.rest.servlet.WebConfigurer.<init>(WebConfigurer.java:29)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:143)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4854)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
log4j:ERROR Either File or DatePattern options are not set for appender [TransactionFileAppender].

这是我的项目中的log4j文件:

<!-- GENERAL APPLICATION/SERVICE APPENDER -->
    <appender name="ServiceFileAppender" class="org.apache.log4j.DailyRollingFileAppender">
        <param name="File" value="/web/logs/gcs-partneronboardingtool/gcs-partneronboardingtool-explorer.log" />
        <param name="DatePattern" value="'.'yyyy-MM-dd" />
        <param name="encoding" value="UTF-8" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%nUUID=%X{USER_CONTEXT}%n%p %c{1} %d{dd MMM yyyy HH:mm:ss,SSS} - %m%n" />
        </layout>
    </appender>

当我在windows中的eclipse中运行tomcat时,日志文件是在c:/web/logs/gcs partneronboardingtool/下创建的。对于mac,我需要做哪些配置更改才能生成这些日志文件?我试了差不多两天,没有找到任何解决办法。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题