Logging File is not get generated on path src/main/resources | Using Spring boot 3.1.2 | Ubuntu

28 views Asked by At

  1. I am trying to integrate the logger with File appender but why the file is not get generated automatically while run the spring boot application.

Below are my log4j2.xml configuration file

    <PatternLayout>
        <!-- custome formate to see the log message -->
        <Pattern>%d - %c [%M] - (%p) %m %n </Pattern>
        
    </PatternLayout>
    
    </console>
    
    <File name="LogToFile" fileName="logs/myapp.log">
    
        <PatternLayout>
        <!-- custome formate to see the log message -->
        <Pattern>%d - %c [%M] - (%p) %m %n </Pattern>
        
    </PatternLayout>
        
   </File>
   
</Appenders>    

<Loggers>
    <Root level="info">
        <AppenderRef ref="examPortalConsole"/>
        <AppenderRef ref="LogToFile"/>
    </Root>
</Loggers>

POM.XML file dependency

     <!-- log4j neccessary dependency-->
     
     <dependency>
       <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-slf4j-impl</artifactId>
     </dependency>
     
     <dependency>
       <groupId>org.apache.logging.log4j</groupId>
       <artifactId>log4j-api</artifactId>
     </dependency>
    
     <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
     </dependency>

I have successfully got the console appender log but failed to integrate the File appender because on path src/main/resources not get generated automatically file .

0

There are 0 answers