I have a Spring Boot app with the following application.yml
logging:
file: logs/api.log
pattern:
file: "%d %-5level [%thread] %logger{0} : %msg%n"
level:
org.springframework.web: INFO
guru.springframework.controllers: INFO
org.hibernate: INFO
which works fine in tomcat 7 and the api.log file was under /logs directory
when I move the app to tomcat 8.5 all the logs are going to catalina.out
I tried also with
logging:
path: /logs
file: api.log
I made a global search for api.log but the file does not exist on the server
Related
For some reason, my log4j configuration file is getting ignored.
The configuration is file found in
C:\dev\pa-backup-restore-utility\BackupRestore\log4j2.properties
Here are the contents of the file:
name=PropertiesConfig
property.filename = logs
appenders = console, file
appender.console.type = Console
appender.console.name = STDOUT
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n
appender.file.type = File
appender.file.name = LOGFILE
appender.file.fileName=logs/backupRestore.log
appender.file.layout.type=PatternLayout
appender.file.layout.pattern=[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n
loggers=file
logger.file.name=log4j2.properties
logger.file.level = error
logger.file.appenderRefs = file
logger.file.appenderRef.file.ref = LOGFILE
rootLogger.level = error
rootLogger.appenderRefs=stdout,logfile
rootLogger.appenderRef.stdout.ref=STDOUT
rootLogger.appenderRef.logfile.ref=LOGFILE
The batch file that runs the class is located in the same directory as the configuration file.
The command from the batch file is run as follows:
set javaPath="%appDir%\jre\bin\java.exe"
%javaPath% -Dapp.properties.path=windows.app.properties -Dlog4j.configurationFile=file:log4j2.properties -jar backupRestore-jar-with-dependencies.jar -b
The entry in pom.xml for this is:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
<version>2.16.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.36</version>
</dependency>
Here's how a logger.info is called:
static void printWarning(String message) {
logger.info("============== warning ===============================");
logger.info("== " + message);
logger.info("============== warning ===============================");
}
However, when I run the batch job, an info message gets displayed in the console:
[main] INFO com.sick.backup.util.Utils - ============== warning ===============================
[main] INFO com.sick.backup.util.Utils - == here is an example message
[main] INFO com.sick.backup.util.Utils - ============== warning ===============================
Also, a log file is no longer getting generated.
This was all working at what point. I'm trying to track down the version to make sure it matches, but the only change I've made is to upgrade the version of log4j-to-slf4j due to prevent a vulnerability.
I am using Log4J along with Springboot in my J2EE based WebApp.
It throws illegal char <:> exception while processing Appender File.
Log4J version: 2.11.1
The logger properties in my application.properties file are as below
logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n
logging.pattern.file=%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n
logging.file=log\\web.log
I understand that it's because of the character colon ':' , but even after trying out different patterns, I still get the same error message.
I don't know where the ${sys:LOG_PATH} part is coming from and how to fix this.
Can someone please help.
Attaching the error stack trace as well.
Thanks in advance :)
Running spring boot/java test project using maven through terminal is not printing logs.However when I run the project through Intellij(run configuration), it does print logs.
I have tried enable logging for spring boot by enabling logs in application.yml file but it didn't work. I have also observed that since intellij uses java to run the test project logging works however I am using maven from terminal so it doesn't work.
logging:
level:
root: INFO
org.package INFO
Enable logs in spring boot java project that prints stuff on terminal.
Besides from the indentation, you are missing the:
logging:
level:
root: INFO
org.package: INFO
Also, you can configure the Logback for Spring-Boot, here is how to: logback
Basically, creating a logback.xml file in the resources path, with the content of:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<logger name="org.springframework.web" level="DEBUG"/>
</configuration>
Here it is also another great tutorial: here
Using spring boot application.yml and logback.xml property files.
I tried with below application.yml properties but its not working.
spring.logging.level.org.apache.kafka:
clients.consumer.ConsumerConfig: INFO
clients.producer.ProducerConfig: INFO
common.utils.AppInfoParser: INFO
Try putting this in config file
<logger name="org.apache.zookeeper" level="OFF"/>
Similarly for kafka.
I am using spring, java 1.5 and tomcat 5.5.
Trying to deploy war in tomcat, but when I am trying, it is giving only
SEVERE: Error listenerStart
after that for printing full tomcat log trace, I have added following log4j.properties file under the WEB-INF/classes folder
log4j.rootLogger=DEBUG, Appender1,Appender2
log4j.appender.Appender1=org.apache.log4j.ConsoleAppender
log4j.appender.Appender1.layout=org.apache.log4j.PatternLayout
log4j.appender.Appender1.layout.ConversionPattern=%-7p %d [%t] %c %x - %m%n
log4j.appender.Appender2=org.apache.log4j.FileAppender
log4j.appender.Appender2.File=applog.txt
log4j.appender.Appender2.layout=org.apache.log4j.PatternLayout
log4j.appender.Appender2.layout.ConversionPattern=%-7p %d [%t] %c %x - %m%n
But after creating war file with ANT, log4j.properties automatically deleting
so please suggest what am I doing wrong.