Logs not getting printed while running topology on Apache Storm Cluster - java

Log file is getting created and logs are getting written into it.But,when I run it on the cluster it writes only the log messages which are specified in the main method.It does not write the logs messages specified in the bolts and spouts.
log4j.rootLogger=TRACE,error,R
# Direct log messages to stdout
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
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.MaxFileSize=20MB
log4j.appender.R.File= /home/ubuntu/Documents/logsInfer/ConsumerStorm.log
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss,SSS} %r [%t] %-5p %c - %m%n
log4j.appender.R.MaxBackupIndex=10
log4j.appender.Con=org.apache.log4j.ConsoleAppender
log4j.appender.Con.layout=org.apache.log4j.PatternLayout
log4j.appender.Con.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss,SSS} %r [%t] %-5p %c - %m%n

Related

Logs are overriding with new date and log file data is getting overrides

Log files are getting overrides. And the log files names are chaining with a new date.
In log folder file data is getting changed and yesterday log is changing to today log.
# Root logger option
log4j.rootLogger=DEBUG, stdout, file, INFO, ERROR, FATAL, WARN
# 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
# Redirect log messages to a log file
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
#outputs to Tomcat home
log4j.appender.file.File=/home/Test/app.log
log4j.appender.file.File=c:/testLogs/app.log
log4j.appender.file.DatePattern='.'yyyy-MM-dd
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
log4j.appender.file.Append=true

Log4j's RollingFileAppender doesn't create a file

I have a Spring Boot application which uses Log4j. I've set up RollingFileAppender and ConsoleAppender. The second one works fine, but RollingFile Appender doesn't create a file.
Here's a file with properties:
log4j.rootLogger=DEBUG, 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
# Redirect log messages to a log file, support file rolling.
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=log4j-application.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
Any ideas will be very appreciated.
Use this configurarion
log4j.rootLogger=DEBUG, consoleAppender, fileAppender
log4j.appender.consoleAppender=org.apache.log4j.ConsoleAppender
log4j.appender.consoleAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.consoleAppender.layout.ConversionPattern=[%t] %-5p %c %x - %m%n
log4j.appender.fileAppender=org.apache.log4j.RollingFileAppender
log4j.appender.fileAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.fileAppender.layout.ConversionPattern=[%t] %-5p %c %x - %m%n
log4j.appender.fileAppender.File=demoApplication.log
For more info visit this link http://howtodoinjava.com/2013/04/08/how-to-configure-log4j-using-properties-file/
Or maybe you can try the following for daily-logging
log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.logfile.File=logfile.log
log4j.appender.logfile.Threshold = INFO
log4j.appender.logfile.DatePattern='_'yyyyMMdd'.log'
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n

Log4j.properties not producing timestamp

I am new to using Apache's Log4J and am trying to be able to produce a timestamp with every bit of Logging it does on a program I am building. However, when I run the program in Eclipse, Log4j is only producing the message I have in my code (without the timestamp). I am thinking it has something to do with how I have my Log4j.properties file set up:
log4j.rootLogger=INFO, file
log4j.rootLogger=DEBUG, file
log4j.rootLogger=WARNING, file
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
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=/home/ryan/workspace/wheel/src/main/resources/logging/application.log
log4j.appender.file.MaxFileSize=20MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
Whenever I try something like this in my code:
logger.info("Connecting to Server")
This is what I see in my log file:
Connecting to Server
Does anyone have any suggestions?
this is incorrect
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
it should be
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

How to create multiple log files using log4j

I want to create separate log file
one for info another for debug,
I am using below log4j.property file,
Please suggest how to modify for two level logging in different file,
# Root logger option
log4j.rootLogger=info, file
# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=infoLog.log
log4j.appender.file.MaxFileSize=10MB
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} - %m%n
log4j.rootCategory=DEBUG, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1} - %m%n
log4j.appender.console.Target=System.out
I would like to request Please send me updated property file rather than giving pointer for search or explore, because I have already spent 3-4 Hours on searching this solution in Google and StackOverflow,
Thanks in advance.
I hope this will help
log4j.rootLogger=INFO,Appender2
log4j.logger.infoMessagesLogger=INFO, infoMessagesAppender
log4j.additivity.infoMessagesLogger=false
log4j.logger.debugMessagesAppender=DEBUG, debugAppenderAll
log4j.additivity.debugMessagesAppender=false
log4j.appender.Appender2=org.apache.log4j.RollingFileAppender
log4j.appender.Appender2.File=generic.log
log4j.appender.Appender2.MaxFileSize=20MB
log4j.appender.Appender2.MaxBackupIndex=10
log4j.appender.Appender2.layout=org.apache.log4j.PatternLayout
log4j.appender.Appender2.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss } %-5p %c %x -%m%n
log4j.appender.infoMessagesAppender=org.apache.log4j.RollingFileAppender
log4j.appender.infoMessagesAppender.File=info.log
log4j.appender.infoMessagesAppender.MaxFileSize=20MB
log4j.appender.infoMessagesAppender.MaxBackupIndex=10
log4j.appender.infoMessagesAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.infoMessagesAppender.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss } %-5p %c %x -%m%n
log4j.appender.debugAppenderAll=org.apache.log4j.RollingFileAppender
log4j.appender.debugAppenderAll.File=debug.log
log4j.appender.debugAppenderAll.MaxFileSize=20MB
log4j.appender.debugAppenderAll.MaxBackupIndex=10
log4j.appender.debugAppenderAll.layout=org.apache.log4j.PatternLayout
log4j.appender.debugAppenderAll.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss } %-5p %c %x -%m%n

Disable log4j console logging and enable file logging

My log4j.properties file is:
log4j.rootLogger=WARN, stdout, file
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d [%t] %p [%c] - %m%n
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=${jboss.server.log.dir}/afrodite.log
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.Append=true
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d [%t] %p [%c] - %m%n
log4j.logger.info.release.scheduler=INFO, scheduler
log4j.appender.scheduler=org.apache.log4j.RollingFileAppender
log4j.appender.scheduler.File=${jboss.server.log.dir}/afrodite_scheduler.log
log4j.appender.scheduler.MaxFileSize=10MB
log4j.appender.scheduler.MaxBackupIndex=10
log4j.appender.scheduler.Append=true
log4j.appender.scheduler.layout=org.apache.log4j.PatternLayout
log4j.appender.scheduler.layout.ConversionPattern=%d [%t] %p [%c] - %m%n
If I want to disable console output for scheduler logger what should I do? That means scheduler logger only log into file not in console.
Thanks and Regards.
Add this line to your config:
log4j.appender.scheduler.additivity=false
log4j.additivity.info.release.scheduler=false
(sorry, first hint was incorrect.)
you can add two lines in your properties file.
log4j.rootLogger=ALL, stdout, file,scheduler (#here ALL declare for all level of logs)
log4j.logger.info.release.scheduler=INFO, scheduler
log4j.additivity.info.release.scheduler=false

Categories

Resources