# Начало работы

Начнем с классического примера для большинства языков программирования - вывод строки "Hello world!". В нашем случае, её логирование.

```
package ru.log4j.Log4jHelloWorld;

import org.apache.log4j.Logger;

/**
 * Hello world!
 */
public class App {
    public static final Logger LOG=Logger.getLogger(App.class);
   public static void main(String[] args) {
       LOG.info("Hello World!");
   }
}
```

Настроим вывод log4j на экран:

```
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

  <appender name="console" class="org.apache.log4j.ConsoleAppender">
    <param name="Target" value="System.out"/>
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%p %c: %m%n"/>
   </layout>
 </appender>
 <!--Корневой logger-->
 <root>
   <priority value ="debug" />
   <appender-ref ref="console" />
 </root>
```

\</log4j:configuration>

Вопрос 1

```
Зачем используются системы логирования в программах?
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://comaqa.gitbook.io/java-automation/log4j-sistema-logirovaniya-soobshenii-v-java/nachalo-raboty.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
