Why is the catalina.home_IS_UNDEFINED directory generated by the Backup journal in the same project directory?

I wrote a log configuration file for my application, but when I did maven clean install (mvn clean install), it generated a catalina.home_IS_UNDEFINED directory with a log file in the project directory. Why is this directory created?

I do not want this to be in my project directory.

Any help to solve this problem?

Here is the configuration file.

<?xml version="1.0" encoding="UTF-8" ?> <configuration> <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>%date{HH:mm:ss.SSS} %-5p [%t] %c{1} - %m%n</pattern> </encoder> </appender> <appender name="MY_APP_LOG" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${catalina.home}/logs/myApplication.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <FileNamePattern>${catalina.home}/logs/myApplication.%d{yyyy-MM-dd}.log</FileNamePattern> </rollingPolicy> <encoder> <pattern>%-5p %date{HH:mm:ss.SSS} [%t] %c{1} - %m%n</pattern> </encoder> <append>true</append> </appender> <logger name="org.springframework" level="WARN"/> <root> <priority value="INFO"/> <appender-ref ref="CONSOLE"/> <appender-ref ref="MY_APP_LOG"/> </root> </configuration> 
+10
java tomcat logback
source share
4 answers

Background

Error loading this property because it is populated only by tomcat. It is not populated with the maven compile job .

Solution 1

Set a property like this in logback.xml

 <?xml version="1.0" encoding="UTF-8"?> <configuration> <if condition='isDefined("catalina.home")'> <then> <property name="log.folder" value="${catalina.home}/logs"/> </then> <else> <property name="log.folder" value="./target/logs"/> </else> </if> <appender name="companyMyAppServiceAppender" class="ch.qos.logback.core.FileAppender"> <file>${log.folder}/company.myApp.log</file> ... </appender> ... </configuration> 

This will create the log files in the target folder at compile time, which will be deleted using clean.

Decision 2

The value of "Rewrite":

 <property name="log.folder" value="./target/logs"/> <if condition='isDefined("catalina.home")'> <then> <property name="log.folder" value="${catalina.home}/logs"/> </then> </if> 

NB!

And don't forget to import maven janino dependency

 <!-- The org.codehaus.janino:commons-compiler:2.7.8 dependency --> <!-- will be automatically pulled in by Maven transitivity rules --> <dependency> <groupId>org.codehaus.janino</groupId> <artifactId>janino</artifactId> <version>2.7.8</version> </dependency> 
+11
source share

I had a similar problem and decided that it was caused by my unit tests that did not have the proper Tomcat environment.

My minimal solution was to add the following src/test/resources/logback.xml to my Maven project project:

 <?xml version="1.0" encoding="UTF-8"?> <configuration> <property name="catalina.home" value="target" /> </configuration> 

The logs generated by unit tests then ended up in the target directory, and not in the top-level directory of the project.

+4
source share

I would advise you not to rely on janino dependency (in this case 1 MB for nothing). There is a simpler solution using the default implementation for logback, for example:

 <?xml version="1.0" encoding="UTF-8"?> <configuration> <property name="base.folder" value="${catalina.home:-./target}"/> <appender name="MY_APP_LOG" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${base.folder}/logs/myApplication.log</file> ... </appender> ... </configuration> 

Find the characters :- between the variable name and the default value. If the variable ${catalina.home} empty, the default value (in this case ./target ) will be used.

0
source share

Try changing:

 <logger name="org.springframework" level="WARN"/> 

in

 <logger name="org.springframework" level="OFF"/> 
-3
source share

All Articles