Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

What Is The Purpose Of User Configuration Of Jdbcappender?

Answer»

USERSETS the DATABASE user NAME.

user − Sets the database user name.

2.

What Is The Purpose Of Url Configuration Of Jdbcappender?

Answer»

URLSETS the JDBC URL.

URL − Sets the JDBC URL.

3.

What Is The Purpose Of Sql Configuration Of Jdbcappender?

Answer»

sql − Specifies the SQL statement to be executed EVERY TIME a LOGGING EVENT OCCURS. This could be INSERT, UPDATE, or DELETE.

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

4.

What Is The Purpose Of Password Configuration Of Jdbcappender?

Answer»

PASSWORDSETS the DATABASE password.

password − Sets the database password.

5.

What Is The Purpose Of Driver Configuration Of Jdbcappender?

Answer»

DRIVERSETS the driver class to the SPECIFIED string. If no driver class is specified, it DEFAULTS to sun.jdbc.odbc.JdbcOdbcDriver.

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

6.

How Will You Put The Logs In Database Using Log4j?

Answer»

The log4j API PROVIDES the org.apache.log4j.jdbc.JDBCAppender object, which can PUT logging INFORMATION in a SPECIFIED database.

The log4j API provides the org.apache.log4j.jdbc.JDBCAppender object, which can put logging information in a specified database.

7.

How Will You Set The Datepattern Using Log4j.properties?

Answer»

FOLLOWING CODE CONFIGURES a DATEPATTERN

# SET the DatePattern
log4j.appender.FILE.DatePattern = '.' yyyy-MM-dd-a

Following code configures a DatePattern −

# Set the DatePattern
log4j.appender.FILE.DatePattern = '.' yyyy-MM-dd-a

8.

How Will You Configure A Dailyrollingfileappender Using Log4j.properties?

Answer»

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

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

9.

How Will You Configure Your Log To Roll Over On The First Day Of Each Week Depending Upon The Locale?

Answer»

'.' yyyy-ww − ROLL over on the first day of each WEEK DEPENDING UPON the locale.

'.' yyyy-ww − Roll over on the first day of each week depending upon the locale.

10.

How Will You Configure Your Log To Roll Over Every Minute?

Answer»

'.' yyyy-MM-dd-HH-mm − ROLL over EVERY MINUTE.

'.' yyyy-MM-dd-HH-mm − Roll over every minute.

11.

How Will You Configure Your Log To Roll Over At The Top Of Every Hour?

Answer»

'.' yyyy-MM-dd-HH − ROLL over at the TOP of EVERY HOUR.

'.' yyyy-MM-dd-HH − Roll over at the top of every hour.

12.

How Will You Configure Your Log To Roll Over At Midday And Midnight Of Each Day?

Answer»

'.' yyyy-MM-dd-a − ROLL over at MIDDAY and MIDNIGHT of each DAY.

'.' yyyy-MM-dd-a − Roll over at midday and midnight of each day.

13.

How Will You Configure Your Log To Roll Over At Midnight Each Day?

Answer»

'.' yyyy-MM-dd − ROLL over at MIDNIGHT each DAY. This is the DEFAULT VALUE.

'.' yyyy-MM-dd − Roll over at midnight each day. This is the default value.

14.

How Will You Configure Your Log To Roll Over At The End Of Each Month And At The Beginning Of The Next Month?

Answer»

'.' yyyy-MM − ROLL over at the END of each MONTH and at the BEGINNING of the NEXT month.

'.' yyyy-MM − Roll over at the end of each month and at the beginning of the next month.

15.

What Is The Purpose Of Datepattern Property Of Dailyrollingfileappender Class?

Answer»

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.

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.

16.

How Will You Generate Your Log Files On A Daily Basis?

Answer»

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.

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.

17.

What Happens If Last Log File Reaches The Maximum Size While Using Rollingfileappender?

Answer»

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.

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.

18.

What Happens If Logs Exceeding The Maximum Size While Using Rollingfileappender?

Answer»

A NEW LOG FILE will be CREATED.

A new log file will be created.

19.

How Will You Configure Maximum Files To Be Used To Log Data Using Log4j.properties?

Answer»

Following code configures maximum FILES to be used −

# SET the the BACKUP index
log4j.appender.FILE.MaxBackupIndex=2

Following code configures maximum files to be used −

# Set the the backup index
log4j.appender.FILE.MaxBackupIndex=2

20.

How Will You Configure Maximum File Size Before Rollover Using Log4j.properties?

Answer»

Following CODE configures maximum FILE size before ROLLOVER

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

Following code configures maximum file size before rollover −

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

21.

How Will You Configure A Rollingfileappender Using Log4j.properties?

Answer»

Following CODE CONFIGURES a RollingFileAppender −

# Define the root LOGGER with APPENDER FILE
log4j.rootLogger = DEBUG, FILE
# Define the file appender
log4j.appender.FILE=org.apache.log4j.RollingFileAppender

Following code configures a RollingFileAppender −

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

22.

What Is Default Value Of Maxbackupindex Property Of Rollingfileappender Class?

Answer»

DEFAULT VALUE is 1.

Default value is 1.

23.

What Is The Purpose Of Maxbackupindex Property Of Rollingfileappender Class?

Answer»

This property DENOTES the NUMBER of backup FILES to be CREATED.

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

24.

What Is Default Value Of Maxfilesize Property Of Rollingfileappender Class?

Answer»

DEFAULT VALUE is 10 MB.

Default value is 10 MB.

25.

What Is The Purpose Of Maxfilesize Property Of Rollingfileappender Class?

Answer»

This is the CRITICAL SIZE of the FILE above which the file will be ROLLED.

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

26.

If You Want To Write Your Logging Information Into Multiple Files Then How Will You Proceed?

Answer»

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.

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.

27.

How Will You Set The Append To False, Overwrite Using Log4j.properties?

Answer»

FOLLOWING code SETS the append to FALSE, overwrite −

# Set the append to false, overwrite
log4j.appender.FILE.Append=false

Following code sets the append to false, overwrite −

# Set the append to false, overwrite
log4j.appender.FILE.Append=false

28.

How Will You Set The Threshold To Debug Mode Using Log4j.properties?

Answer»

FOLLOWING CODE SETS the THRESHOLD to debug mode −

# Set the threshold to debug mode
log4j.appender.FILE.Threshold=debug

Following code sets the threshold to debug mode −

# Set the threshold to debug mode
log4j.appender.FILE.Threshold=debug

29.

How Will You Configure Immediate Flush To True Using Log4j.properties?

Answer»

Following CODE configures IMMEDIATE FLUSH to true −

# Set the immediate flush to true (default)
log4j.appender.FILE.ImmediateFlush=true

Following code configures immediate flush to true −

# Set the immediate flush to true (default)
log4j.appender.FILE.ImmediateFlush=true

30.

What Is The Purpose Of Buffersize Configuration Of Fileappender?

Answer»

bufferSize − If BUFFERED I/O is ENABLED, it indicates the buffer size. By default, it is set to 8kb.

bufferSize − If buffered I/O is enabled, it indicates the buffer size. By default, it is set to 8kb.

31.

What Is The Purpose Of Bufferedio Configuration Of Fileappender?

Answer»

bufferedIO − This FLAG INDICATES whether we need BUFFERED WRITING enabled. By default, it is set to FALSE.

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

32.

What Is The Purpose Of Fileappend Configuration Of Fileappender?

Answer»

fileAppend − This is by DEFAULT set to true, which MEANS the LOGGING information being appended to the end of the same file.

fileAppend − This is by default set to true, which means the logging information being appended to the end of the same file.

33.

What Is The Purpose Of Filename Configuration Of Fileappender?

Answer»

FILENAME − The NAME of the LOG FILE.

Filename − The name of the log file.

34.

What Is The Purpose Of Threshold Configuration Of Fileappender?

Answer»

THRESHOLD − The threshold LEVEL for this APPENDER.

threshold − The threshold level for this appender.

35.

What Is The Purpose Of Encoding Configuration Of Fileappender?

Answer»

ENCODING − It is POSSIBLE to USE any character-encoding. By DEFAULT, it is the platform-specific encoding SCHEME.

encoding − It is possible to use any character-encoding. By default, it is the platform-specific encoding scheme.

36.

What Is The Purpose Of Immediateflush Configuration Of Fileappender?

Answer»

immediateFlush − This FLAG is by default SET to true, which MEANS the OUTPUT stream to the FILE being flushed with each append operation.

immediateFlush − This flag is by default set to true, which means the output stream to the file being flushed with each append operation.

37.

How Will You Set The Title Of Html Page Generated Using Htmllayout?

Answer»

HTMLLayout.setTitle(STRING) − Sets the title for the HTML FILE. Default is LOG4J LOG Messages.

HTMLLayout.setTitle(String) − Sets the title for the HTML file. Default is log4j Log Messages.

38.

How Will You Set The Location Information For The Logging Event Using Htmllayout?

Answer»

HTMLLayout.setLocationInfo(String) − Sets the LOCATION INFORMATION for the logging EVENT. DEFAULT is false.

HTMLLayout.setLocationInfo(String) − Sets the location information for the logging event. Default is false.

39.

How Will You Set The Content Type Of Html Generated Using Htmllayout?

Answer»

HTMLLayout.setContentType(String) − SETS the content TYPE of the HTML content. DEFAULT is text/html.

HTMLLayout.setContentType(String) − Sets the content type of the HTML content. Default is text/html.

40.

What Kind Of Information Htmllayout Class Provides?

Answer»

It provides the following information to be displayed −

  • The time elapsed from the start of the application before a particular logging event was generated.
  • The NAME of the thread that invoked the logging REQUEST.
  • The LEVEL associated with this logging request.
  • The name of the logger and logging MESSAGE.
  • The optional location information for the program file and the line number from which this logging was invoked.

It provides the following information to be displayed −

41.

If You Want To Generate Your Logging Information In An Html-formatted File, How Will You Proceed?

Answer»

If you want to generate your LOGGING information in an HTML-formatted FILE, then you can use org.apache.log4j.HTMLLAYOUT to format your logging information.

The HTMLLayout CLASS extends the abstract org.apache.log4j.Layout class and overrides the format() method from its base class to provide HTML-style FORMATTING.

If you want to generate your logging information in an HTML-formatted file, then you can use org.apache.log4j.HTMLLayout to format your logging information.

The HTMLLayout class extends the abstract org.apache.log4j.Layout class and overrides the format() method from its base class to provide HTML-style formatting.

42.

What Is The Intent Of %-20.30c Format Modifier?

Answer»

%-20.30c − Right pad with spaces if the CATEGORY NAME is shorter than 20 CHARACTERS. HOWEVER, if category name is longer than 30 characters, then truncate from the beginning.

%-20.30c − Right pad with spaces if the category name is shorter than 20 characters. However, if category name is longer than 30 characters, then truncate from the beginning.

43.

What Is The Intent Of %20.30c Format Modifier?

Answer»

%20.30c − Left pad with SPACES if the CATEGORY name is shorter than 20 characters. However, if the category name is longer than 30 characters, then TRUNCATE from the beginning.

%20.30c − Left pad with spaces if the category name is shorter than 20 characters. However, if the category name is longer than 30 characters, then truncate from the beginning.

44.

What Is The Intent Of %.30c Format Modifier?

Answer»

%.30CTRUNCATE from the BEGINNING if the category name is LONGER than 30 characters.

%.30c − Truncate from the beginning if the category name is longer than 30 characters.

45.

What Is The Intent Of %-20c Format Modifier?

Answer»

%-20c − RIGHT pad with SPACES if the category name is less than 20 CHARACTERS long.

%-20c − Right pad with spaces if the category name is less than 20 characters long.

46.

What Is The Intent Of %20c Format Modifier?

Answer»

%20C − Left pad with spaces if the category NAME is LESS than 20 CHARACTERS long.

%20c − Left pad with spaces if the category name is less than 20 characters long.

47.

What Are Format Modifiers?

Answer»

By default, the RELEVANT INFORMATION is displayed as output as is. However, with the aid of format MODIFIERS, it is possible to change the MINIMUM field WIDTH, the maximum field width, and justification.

By default, the relevant information is displayed as output as is. However, with the aid of format modifiers, it is possible to change the minimum field width, the maximum field width, and justification.

48.

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

Answer»

% − The LITERAL PERCENT SIGN. %% will PRINT a % sign.

% − The literal percent sign. %% will print a % sign.

49.

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

Answer»

X − The X conversion character is followed by the KEY for the MDC. For example, X{clientIP} will print the INFORMATION STORED in the MDC against the key clientIP.

X − The X conversion character is followed by the key for the MDC. For example, X{clientIP} will print the information stored in the MDC against the key clientIP.

50.

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

Answer»

XUSED to output the NDC (NESTED diagnostic context) ASSOCIATED with the thread that generated the logging event.

x − Used to output the NDC (nested diagnostic context) associated with the thread that generated the logging event.