Самые популярные вопросы и ответы для интервью и онлайн-тесты
Образовательная платформа для подготовки к интервью, онлайн-тестов, учебных материалов и живой практики

Развивайте навыки с целевыми маршрутами обучения, пробными тестами и контентом для подготовки к интервью.

WithoutBook объединяет вопросы для интервью по предметам, онлайн-практику, учебные материалы и сравнительные руководства в одном удобном учебном пространстве.

Подготовка к интервью

Пробные экзамены

Сделать домашней страницей

Добавить страницу в закладки

Подписаться по адресу эл. почты
LIVE пробные интервью WithoutBook Log4j Похожие темы для интервью: 39

Interview Questions and Answers

Изучите лучшие вопросы и ответы по Log4j для новичков и опытных кандидатов, чтобы подготовиться к собеседованиям.

Всего вопросов: 35 Interview Questions and Answers

Лучшее LIVE пробное интервью, которое стоит посмотреть перед собеседованием

Изучите лучшие вопросы и ответы по Log4j для новичков и опытных кандидатов, чтобы подготовиться к собеседованиям.

Interview Questions and Answers

Найдите вопрос, чтобы посмотреть ответ.

Вопросы и ответы для опытного / экспертного уровня

Вопрос 1

How do you define logging for your application?

To define logging for your application, you have to download the log4j framework (log4j.jar) from the apache site.
Once log4j jars are downloaded, make sure that these jars are in classpath of your application. lets say you have web-application need to be added log4j. In this case, log4j jars are copied to WEB-INF/lib folder of your web application.
create new file either logging.properties or log4j.xml which will be copied to WEB-INF/classes folder.
logging.properties/log4j.xml contains the all the configuration related to logging mechanism and logger level and package that you want to define logger level.

Example:
logging.properties:
logger.level=INFO
logger.handlers=CONSOLE,FILE,RejRec
handler.RejRec=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
handler.RejRec.level=WARN
handler.RejRec.formatter=RejRec
handler.RejRec.properties=append,autoFlush,enabled,suffix,fileName
handler.RejRec.append=true
handler.RejRec.autoFlush=true
handler.RejRec.enabled=true
handler.RejRec.suffix=.yyyy-MM-dd
handler.RejRec.fileName=E:\Docs\WithoutBook\DID\jboss-eap-6.2\standalone\log\RejectedRecords.log

log4j.xml:
<log4j:configuration>
<appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
        <appender-ref ref="LOG"/>
</appender>

<appender name="MEETING-APP-LOG" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="E:/Softwares/glassfish_dump/glassfish/domains/domain1/logs/meeting_app.log" />
<param name="Append" value="true"/> 
<param name="DatePattern" value="'.'yyyy-MM-dd-a"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd} %d{HH:mm:ss,SSS} %-5p [%t] %c - %m%n" />
</layout>
</appender>

  <logger name="com.withoutbook" additivity="false">
         <level value="warn"/>
         <appender-ref ref="MEETING-APP-LOG"/>
</logger>

     <root>
         <priority value="debug"/>
         <appender-ref ref="ASYNC"/>
         <appender-ref ref="ERROR-LOG"/>
</root>
</log4j:configuration>
Сохранить для повторения

Сохранить для повторения

Добавьте этот элемент в закладки, отметьте как сложный или поместите в набор для повторения.

Открыть мою библиотеку обучения
Это полезно?
Добавить комментарий Посмотреть комментарии
Вопрос 2

What are the other support objects in Log4j?

There are other support objects in the Log4j framework are:

  • Level Object
  • Filter Object
  • Object Renderer
  • Log Manager
Сохранить для повторения

Сохранить для повторения

Добавьте этот элемент в закладки, отметьте как сложный или поместите в набор для повторения.

Открыть мою библиотеку обучения
Это полезно?
Добавить комментарий Посмотреть комментарии
Вопрос 3

Explain whether log4j is a thread safe.

Log4j is a thread-safe, log4j components are built to be used in multithread systems.

Сохранить для повторения

Сохранить для повторения

Добавьте этот элемент в закладки, отметьте как сложный или поместите в набор для повторения.

Открыть мою библиотеку обучения
Это полезно?
Добавить комментарий Посмотреть комментарии
Вопрос 4

Explain whether a log output format can be customized.

Yes, you can extend the layout class to create your own customized log format. Appenders can be parameterized to use the layout of your choice.

Сохранить для повторения

Сохранить для повторения

Добавьте этот элемент в закладки, отметьте как сложный или поместите в набор для повторения.

Открыть мою библиотеку обучения
Это полезно?
Добавить комментарий Посмотреть комментарии
Вопрос 5

What are the system properties checked by log4j?

The system properties checked by log4j are

  • Log4j debug, if true, log4j will show internal debugging messages to the console
  • defaultInitOverride, if true, log4j will not execute default initialization
  • configuration, URL for default initialization configuration file
  • configurationClass, Class name for configurator to execute default initialization configuration file
  • ignoreTCL, if true, the thread class loader will be overlooked when loading classes
Сохранить для повторения

Сохранить для повторения

Добавьте этот элемент в закладки, отметьте как сложный или поместите в набор для повторения.

Открыть мою библиотеку обучения
Это полезно?
Добавить комментарий Посмотреть комментарии
Вопрос 6

What is the role of the filter in log4j?

Filter objects in log4j decide whether logging requests should be handled by a particular Appender or ignored.

Сохранить для повторения

Сохранить для повторения

Добавьте этот элемент в закладки, отметьте как сложный или поместите в набор для повторения.

Открыть мою библиотеку обучения
Это полезно?
Добавить комментарий Посмотреть комментарии
Вопрос 7

How can you get multiple processes to log into the same file?

You may have each process log to a socket Appender. The receiving socket server can receive all the events and send them to a single log file.

Сохранить для повторения

Сохранить для повторения

Добавьте этот элемент в закладки, отметьте как сложный или поместите в набор для повторения.

Открыть мою библиотеку обучения
Это полезно?
Добавить комментарий Посмотреть комментарии
Вопрос 8

What is the difference between Threshold and LevelRangeFilter in log4j?

Both Threshold and LevelRangeFilter do the same thing.

However, the threshold should be faster. Filters enable you to implement your own logic, and you can also link them together if required. If you need a basic threshold functionality, then the “threshold” function will be enough.

Сохранить для повторения

Сохранить для повторения

Добавьте этот элемент в закладки, отметьте как сложный или поместите в набор для повторения.

Открыть мою библиотеку обучения
Это полезно?
Добавить комментарий Посмотреть комментарии
Вопрос 9

What are the format characters used in log4j?

The format characters used in log4j are

  • L – it is used to output the line number from where the logging request was processed or issued
  • m – It is used to output the application-supplied message related to the logging event
  • p – It is used to output the priority of the logging event
  • C – It is used to output the class name of the caller issuing the logging request

When any number is used along with the character it means the priority of the logging event should be justified to a width of 4 characters.

Сохранить для повторения

Сохранить для повторения

Добавьте этот элемент в закладки, отметьте как сложный или поместите в набор для повторения.

Открыть мою библиотеку обучения
Это полезно?
Добавить комментарий Посмотреть комментарии
Вопрос 10

Mention what is the best way to migrate from java.util logging to apache log4j?

The best way to migrate from java.util logged to log4j is to use the global file search/replace method.  It will replace with “org.apache.log4j.Logger”.

Then verify the project with the build.

Сохранить для повторения

Сохранить для повторения

Добавьте этот элемент в закладки, отметьте как сложный или поместите в набор для повторения.

Открыть мою библиотеку обучения
Это полезно?
Добавить комментарий Посмотреть комментарии
Вопрос 11

Why do you get multiple copies of the message in log file sometime?

There could be two reasons why this might happen:

  • Repeated configuration of log4j
  • Attaching the same appenders to multiple loggers
Сохранить для повторения

Сохранить для повторения

Добавьте этот элемент в закладки, отметьте как сложный или поместите в набор для повторения.

Открыть мою библиотеку обучения
Это полезно?
Добавить комментарий Посмотреть комментарии

Самое полезное по оценкам пользователей:

Авторские права © 2026, WithoutBook.