log4j interview question set 2/log4j Interview Questions and Answers for Freshers & Experienced

What is the purpose of sql configuration of JDBCAppender?

sql − Specifies the SQL statement to be executed every time a logging event occurs. This could be INSERT, UPDATE, or DELETE.

What is the purpose of driver configuration of JDBCAppender?

driver − Sets the driver class to the specified string. If no driver class is specified, it defaults to sun.jdbc.odbc.JdbcOdbcDriver.

How will you configure a DailyRollingFileAppender using log4j.properties?

Following code configures a DailyRollingFileAppender −

# Define the root logger with appender file
log4j.rootLogger = DEBUG, FILE
# Define the file appender
log4j.appender.FILE = org.apache.log4j.DailyRollingFileAppender

What is the purpose of DatePattern property of DailyRollingFileAppender class?

This indicates when to roll over the file and the naming convention to be followed. By default, roll over is performed at midnight each day.

How will you generate your log files on a daily basis?

To write your logging information into files on a daily basis, you would have to use org.apache.log4j.DailyRollingFileAppender class which extends the FileAppender class and inherits all its properties.

What happens if last log file reaches the maximum size while using RollingFileAppender?

Once the last 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.

How will you configure maximum file size before rollover using log4j.properties?

Following code configures maximum file size before rollover −

# Set the maximum file size before rollover
log4j.appender.FILE.MaxFileSize=5KB

What is the purpose of maxBackupIndex property of RollingFileAppender class?

This property denotes the number of backup files to be created.

What is the purpose of maxFileSize property of RollingFileAppender class?

This is the critical size of the file above which the file will be rolled.

If you want to write your logging information into multiple files then how will you proceed?

To write your logging information into multiple files, you would have to use org.apache.log4j.RollingFileAppender class which extends the FileAppender class and inherits all its properties.

What Is The Purpose Of F Character Used In The Conversionpattern Of Patternlayout Object?

Used to output the file name wherein the logging request was issued.

What Is The Purpose Of D Character Used In The Conversionpattern Of Patternlayout Object?

Used to output the date of the logging occasion. For instance, %dHH:mm:ss,SSS or %ddd MMM yyyy HH:mm:ss,SSS.

How Will You Define A Root Logger Turning Debug Mode Off?

Following syntax defines the basis logger with WARN mode turning DEBUG mode off.# Define the basis logger with appender file
log = /usr/domestic/log4j
log4j.RootLogger = WARN, FILE

How Do Levels Works?

A log request of degree p in a logger with degree q is enabled if p >= q. This rule is on the heart of log4j. It assumes that levels are ordered. For the same old stages, we have ALL < DEBUG < INFO < WARN < ERROR < FATAL < OFF.

What Is Purpose Of Off Log Level?

OFF − The maximum viable rank and is supposed to turn off logging.

What Is Purpose Of Fatal Log Level?

FATAL − Designates very excessive blunders activities on the way to presumably lead the application to abort.

What Is Purpose Of All Log Level?

ALL − All ranges such as custom levels.

How Will You Print A Log Message In Trace Mode?

public void trace(Object message) of Logger class prints messages with the level Level.TRACE.

What Is The Purpose Of Target In Appender?

goal − The goal may be a console, a record, or every other object depending on the appender.

What Is The Purpose Of Layout Object In Appender?

layout − Appender uses the Layout objects and the conversion sample related to them to layout the logging facts.

What Is The Use Of Log4j.Residences?

The log4j.Houses file is a log4j configuration file which continues properties in key-fee pairs. By default, the LogManager appears for a report named log4j.Properties inside the CLASSPATH.

How will you define a file appender using log4j.properties?

Following syntax defines a file appender −

# Define the file appender
log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.File=${log}/log.out

How will you define a root logger with appender file using log4j.properties?

Following syntax defines the root logger with appender file:

# Define the root logger with appender file
log = /usr/home/log4j
log4j.rootLogger = DEBUG, FILE

What Is The Purpose Of Level Object?

Level Object - The Level object defines the granularity and priority of any logging information. There are seven ranges of logging defined inside the API: OFF, DEBUG, INFO, ERROR, WARN, FATAL, and ALL.

What is the purpose of bufferedIO configuration of FileAppender?

bufferedIO − This flag indicates whether we need buffered writing enabled. By default, it is set to false.

Search
R4R Team
R4R provides log4j Freshers questions and answers (log4j Interview Questions and Answers) .The questions on R4R.in website is done by expert team! Mock Tests and Practice Papers for prepare yourself.. Mock Tests, Practice Papers,log4j interview question set 2,log4j Freshers & Experienced Interview Questions and Answers,log4j Objetive choice questions and answers,log4j Multiple choice questions and answers,log4j objective, log4j questions , log4j answers,log4j MCQs questions and answers Java, C ,C++, ASP, ASP.net C# ,Struts ,Questions & Answer, Struts2, Ajax, Hibernate, Swing ,JSP , Servlet, J2EE ,Core Java ,Stping, VC++, HTML, DHTML, JAVASCRIPT, VB ,CSS, interview ,questions, and answers, for,experienced, and fresher R4r provides Python,General knowledge(GK),Computer,PHP,SQL,Java,JSP,Android,CSS,Hibernate,Servlets,Spring etc Interview tips for Freshers and Experienced for log4j fresher interview questions ,log4j Experienced interview questions,log4j fresher interview questions and answers ,log4j Experienced interview questions and answers,tricky log4j queries for interview pdf,complex log4j for practice with answers,log4j for practice with answers You can search job and get offer latters by studing r4r.in .learn in easy ways .