hello guys welcome to this lecture today we will see how to do logging in files to write your logging information to a file you would have to use apache log4j dot file appender so file appender configuration has following parameters first one is immediate flush this is a flag which is by default set to true which means the output stream to the file being flushed with each append operation it means that the output stream to the file being flushed with each append operation encoding it is possible to use any character encoding by default it is the platform specific encoding scheme next property is threshold the threshold level you could set the threshold level for each and every appender along with the level which is set at the root level file name this is the name of the log file file append this is by default set to true which means logging information will be intended by default it is set to false buffer size if buffered input output is enabled it indicates the buffer size by default it is 8 KB we could also do logging in multiple files this is called rolling files whenever you’re logging file reaches maximum size you know it would be difficult to load the data and that file would become really heavy so what the developers have done is they have come up with the rolling files method when a file reaches a particular size then what we do is we roll out I mean you create additional files and all the old data is dumped to that to file the log files when they reach maximum memory the old log files will start getting deleted so to write your logging information into multiple files you would use rolling file appender class which extends the file appender class and it inherits all its properties one of the property is maximum file size this is the critical size of the file above which the file will be rolled default value is 10 MB and maximum backup index this property denotes the number of backup files need to be created the default values so if we said let’s say if we set maximum permissible size of each log file is 5 MB upon exceeding this maximum size a new log file will be created also if let’s say if you have set maximum backup index as 2 then once the second log file reaches the maximum size the first log file will be erased and thereafter all the logging information will be rolled back to the first log file and let’s take another scenario where you want to log daily daily information in the file so daily log file generation they may be a requirement to generate your log files on a daily basis to keep a clean record of your logging information so in that case you would use daily rolling file appender class which is also again a subclass of a file appender and it inherits all its properties along with that it comes with another property date pattern this indicates when to roll over the file and the naming convention to be followed by default rollover is performed at midnight each day there are several different patterns which you could use in in order to schedule your rollover I will be attaching all of these information with an equal to go through it

Tags:






Youtube
Facebook
Google Plus
Twitter
TutorialDrive


Apache Zookeeper Tutorial

Apache Kafka Tutorial

Apache Kafka Security

Elasticserarch n Kibana

Java 8 Tutorial

Log4J Tutorial

Apache Storm Tutorial

SQLite Tutorial

Apache Ant Tutorial

Related Posts

blog

Apache Kafka Commands Cheat sheet

Spread the loveKafka Topics List existing topics bin/kafka-topics.sh –zookeeper localhost:2181 –list Purge a topic bin/kafka-topics.sh –zookeeper localhost:2181 –alter –topic mytopic –config retention.ms=1000 … wait a minute … bin/kafka-topics.sh –zookeeper localhost:2181 –alter –topic mytopic –delete-config retention.ms
Read more…

blog

What is Apache Maven | Apache Maven complete tutorial from scratch pdf

Spread the love In this post you will learn the complete tutorial of Apache Maven build tool What is Maven ? Apache Maven is a software project management and comprehension tool. Based on the concept
Read more…

blog

Practical Guide for Web Development in 2018

Spread the loveWelcome to my practical guide  for web development in 2018 in terms of  technology and career. Before we start I just want to  mention a few things, you don’t need to learn  everything that
Read more…