dev90
dev90

Reputation: 7591

How to print log on Tomcat logs folder

I am using Log4j to print logs. Its successfully print the logs on spring console, but i need to check, how its printing them on catalina. Normally on server we write this tail -f /var/log/tomcat8/catalina.out, but how to view this on local machine.

This is what i am doing to print the logs

logger.info("Log4J - "+ "Request: " + 
                ",URL= "+ httprequest.getRequestURI()+
                ",requestId= "+ uniqueID+  ",Headers= "+ map);

Kindly guide me how and where to check catalina logs.

I have tried to run Tomcat8.5 server from cmd. It starts the server, and put some logs in tomcat/logs folder, but nothings is related to the application. When i open the service from browser, it does not add anything in the log.

This is what it writes in catalina.2017-03-19

19-Mar-2017 21:08:38.766 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [http-nio-8080] 19-Mar-2017 21:08:38.771 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [ajp-nio-8009] 19-Mar-2017 21:08:38.772 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 1092 ms

EDIT

This is my properties file, it prints the logs in the file mentioned here.C:\\log\\logging.log

# Root logger option
log4j.rootLogger=INFO, stdout, file

# Redirect log messages to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n


# Redirecting to Tomcat Logger

log4j.appender.file.File=${catalina.home}logs/logging.log


# Redirect log messages to a log file, support file rolling.

log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=C:\\log\\logging.log
log4j.appender.file.MaxFileSize=5MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

Upvotes: 1

Views: 5659

Answers (1)

SANTOSHKUMAR SINGH
SANTOSHKUMAR SINGH

Reputation: 476

Check application log. logging.properties file for more details.

Log write output in catalina.out if application log is not configured.

Where is your logging.properties file located? It should be available in the root of the classpath. As a sanity check, what does the following code print?

System.out.println(getClass().getClassLoader().getResource("logging.properties"));

If the code is in a static context, use

System.out.println(ClassName.class.getClassLoader().getResource("logging.properties"));

Upvotes: 1

Related Questions