简体   繁体   中英

issue with my log4j2 setup

I was using log4j2 and it was logging statements for me with no issues. I might have made some changes (moved from info to debug and back) but its quite possibly I might have messed up the config in some other fashion. I am copying my config file below (I have not moved any log4j2 and slf4j jar files from my project). Any thoughts?

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="debug" name="TestApp" packages="">
  <Appenders>
    <RollingRandomAccessFile name="RollingRandomAccessFile" fileName="logs/test.log" immediateFlush="false" append="false"
                 filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log.gz">
      <PatternLayout>
        <Pattern>%d %p %c{1.} [%t] %m %ex%n</Pattern>
      </PatternLayout>
      <Policies>
        <TimeBasedTriggeringPolicy />
        <SizeBasedTriggeringPolicy size="500 MB"/> 
      </Policies>
    </RollingRandomAccessFile>
  </Appenders>
  <Loggers>
      <AsyncLogger name="FATAL_LOGGER" level="fatal" includeLocation="true" additivity="false">  
      <AppenderRef ref="RollingRandomAccessFile"/>
    </AsyncLogger>
    <Root level="debug" includeLocation="false">
      <AppenderRef ref="RollingRandomAccessFile"/>
    </Root>
  </Loggers>
</Configuration>

I tested the config in a test project and it works without any issues. Ensure that you do not have any locks on the file and have correct read/write privileges on the file/directory.

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