Error statuslogger unrecognized format specifier

When using maven-shade-plugin or maven-assembly-plugin to mark the project into an executable JAR package, if you import log4j2, the following problems will occur:

problem

When using maven-shade-plugin or maven-assembly-plugin to mark the project into an executable JAR package, if you import log4j2, the following problems will occur:

ERROR StatusLogger Unrecognized format specifier [d]
ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [thread]
ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [level]
ERROR StatusLogger Unrecognized conversion specifier [level] starting at position 35 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [logger]
ERROR StatusLogger Unrecognized conversion specifier [logger] starting at position 47 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [msg]
ERROR StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [n]
ERROR StatusLogger Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.

Solution

Add the following configuration to pom.

< plugin > 
   < groupId > org.apache.maven.plugins </ groupId > 
   < artifactId > maven-shade-plugin </ artifactId > 
   < version > 2.4.3 </ version > 
   < executions > 
       < execution > 
           < phase > package < / phase > 
           < goals > 
               < goal > shade </ goal > 
           </ goals > 
           <configuration > 
               < filters > 
                   < filter > 
                       < artifact > *:* </ artifact > 
                       < excludes > 
                           < exclude > META-INF/*.SF </ exclude > 
                           < exclude > META-INF/*.DSA </ exclude > 
                           < exclude > META-INF/*.RSA </ exclude > 
                       </ excludes > 
                   </ filter > 
               </ filters > 
               <finalName> ${artifactId}-${env}-${version} </ finalName > 
               < transformers > 
                   < transformer
                            implementation ="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer" > 
                       < mainClass > xxx.yyyy.zzz .Main </ mainClass > 
                   </ transformer > 
                   < transformer implementation ="org.apache.maven.plugins.shade.resource.AppendingTransformer" > 
                       < resource > META-INF/spring.handlers </ resource >
                   </transformer > 
                   < transformer implementation ="org.apache.maven.plugins.shade.resource.AppendingTransformer" > 
                       < resource > META-INF/spring.schemas </ resource > 
                   </ transformer > 
                   < transformer implementation ="org.apache.maven .plugins.shade.resource.AppendingTransformer" > 
                       < resource > META-INF/spring.tooling </ resource > 
                   </ transformer > 
                   < transformer
                            implementation="org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer" /> 
                   < transformer
                            implementation ="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" /> 
                   < transformer implementation ="com.github.edwgiz. mavenShadePlugin.log4j2CacheTransformer.PluginsCacheFileTransformer"  /> 
               </ transformers > 
           </ configuration > 
       </ execution > 
   </ executions > 
   < dependencies > 
       < dependency > 
           <groupId >com.github.edwgiz </ groupId > 
           < artifactId > maven-shade-plugin.log4j2-cachefile-transformer </ artifactId > 
           < version > 2.6.1 </ version > 
       </ dependency > 
   </ dependencies > 
</ plugin >

Cause Analysis

log4j2 is plug-in programming. When the log4j2 package is compiled, or the package containing the log4j2 plug-in is compiled, the plug-in information that needs to be loaded will be placed in META-INF/org/apache/logging/log4j/core/config/plugins/ Log4j2Plugins.dat (including the official logj42 native plug-in), and then when the project starts, log4j2 will scan the plug-in information file in the META-INF directory of each jar package, and then load the plug-in.

But when the project is marked as a jar package, if there are Log4j2Plugins.dat files in two different jar packages, there will be a problem, one of the files will be overwritten by the other, resulting in a file when the project starts The plug-in cannot be loaded normally, resulting in an error.

To solve this problem, when all jar packages are labeled as one jar package, the Log4j2Plugins.dat in each jar package needs to be merged. This is what the maven-shade-plugin.log4j2-cachefile-transformer package does.

Read More:

My maven dependency:

        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-lambda-java-log4j2</artifactId>
            <version>1.2.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.8.0-beta4</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.14.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.14.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j18-impl</artifactId>
            <version>2.14.0</version>
        </dependency>  

example Java code:

import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.events.SNSEvent;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class LogTest implements RequestHandler<SNSEvent, String> {
    @Override
    public String handleRequest(SNSEvent snsEvent, Context context) {
        log.trace("This is trace");
        log.debug("This is debug");
        log.info("This is info");
        log.warn("This is warn");
        log.error("This is error");
        return "logged";
    }
}

my log4j2.xml:

<Configuration status="WARN">
    <Appenders>
        <Lambda name="Lambda">
            <PatternLayout>
                <pattern>%d{yyyy-MM-dd HH:mm:ss} %X{AWSRequestId} %-5p %c{1} - %m%n</pattern>
            </PatternLayout>
        </Lambda>
    </Appenders>
    <Loggers>
        <Root level="info">
            <AppenderRef ref="Lambda" />
        </Root>
    </Loggers>
</Configuration>

After deploy to lambda, invoke the lambda and the logs in CloudWatch will be:


2021-03-05T16:32:12.336-05:00 | WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
-- | --
  | 2021-03-05T16:32:12.484-05:00 | ERROR StatusLogger Unrecognized format specifier [d]
  | 2021-03-05T16:32:12.484-05:00 | ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.
  | 2021-03-05T16:32:12.485-05:00 | ERROR StatusLogger Unrecognized format specifier [thread]
  | 2021-03-05T16:32:12.486-05:00 | ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
  | 2021-03-05T16:32:12.486-05:00 | ERROR StatusLogger Unrecognized format specifier [level]
  | 2021-03-05T16:32:12.486-05:00 | ERROR StatusLogger Unrecognized conversion specifier [level] starting at position 35 in conversion pattern.
  | 2021-03-05T16:32:12.486-05:00 | ERROR StatusLogger Unrecognized format specifier [logger]
  | 2021-03-05T16:32:12.486-05:00 | ERROR StatusLogger Unrecognized conversion specifier [logger] starting at position 47 in conversion pattern.
  | 2021-03-05T16:32:12.486-05:00 | ERROR StatusLogger Unrecognized format specifier [msg]
  | 2021-03-05T16:32:12.487-05:00 | ERROR StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in conversion pattern.
  | 2021-03-05T16:32:12.487-05:00 | ERROR StatusLogger Unrecognized format specifier [n]
  | 2021-03-05T16:32:12.487-05:00 | ERROR StatusLogger Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.
  | 2021-03-05T16:32:12.512-05:00 | ERROR StatusLogger Unrecognized format specifier [d]
  | 2021-03-05T16:32:12.512-05:00 | ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.
  | 2021-03-05T16:32:12.512-05:00 | ERROR StatusLogger Unrecognized format specifier [thread]
  | 2021-03-05T16:32:12.513-05:00 | ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
  | 2021-03-05T16:32:12.513-05:00 | ERROR StatusLogger Unrecognized format specifier [level]
  | 2021-03-05T16:32:12.513-05:00 | ERROR StatusLogger Unrecognized conversion specifier [level] starting at position 35 in conversion pattern.
  | 2021-03-05T16:32:12.513-05:00 | ERROR StatusLogger Unrecognized format specifier [logger]
  | 2021-03-05T16:32:12.514-05:00 | ERROR StatusLogger Unrecognized conversion specifier [logger] starting at position 47 in conversion pattern.
  | 2021-03-05T16:32:12.514-05:00 | ERROR StatusLogger Unrecognized format specifier [msg]
  | 2021-03-05T16:32:12.514-05:00 | ERROR StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in conversion pattern.
  | 2021-03-05T16:32:12.514-05:00 | ERROR StatusLogger Unrecognized format specifier [n]
  | 2021-03-05T16:32:12.514-05:00 | ERROR StatusLogger Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.
  | 2021-03-05T16:32:13.007-05:00 | START RequestId: c2f5eb6d-4c51-4833-9663-6b37e6cc9aaf Version: $LATEST
  | 2021-03-05T16:32:13.248-05:00 | END RequestId: c2f5eb6d-4c51-4833-9663-6b37e6cc9aaf

If I remove aws-lambda-java-log4j2 and change appender to a Console appender, the log will back to normal behavior.

Issue

Spring 4.3.30+hibernate 5 application. pom.xml has all the log4j2 dependencies.

 <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-jcl</artifactId>
    <version>${log4j2.version}</version>
  </dependency>
  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>${log4j2.version}</version>
  </dependency>
  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-slf4j-impl</artifactId>
    <version>${log4j2.version}</version>
  </dependency>
  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>${log4j2.version}</version>
  </dependency>
  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-1.2-api</artifactId>
    <version>${log4j2.version}</version>
  </dependency>
  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-to-slf4j</artifactId>
    <version>${log4j2.version}</version>
  </dependency>

even added log4j2.xml

<?xml version="1.0" encoding="UTF-8" ?>
  <Configuration status="TRACE">

  <Appenders>
    <Console name="Console" target="SYSTEM_OUT">
      <PatternLayout pattern="%p [%t] %c{1}.%M(%L) | %m%n"/>
    </Console>
  </Appenders>
  <Loggers>
    <Root level="INFO">
      <AppenderRef ref="Console"/>
    </Root>
  </Loggers>

</Configuration>

The ERROR i have been getting:

ERROR StatusLogger Unrecognized format specifier [d]
ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [thread]
ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [level]
ERROR StatusLogger Unrecognized conversion specifier [level] starting at position 35 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [logger]
ERROR StatusLogger Unrecognized conversion specifier [logger] starting at position 47 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [msg]
ERROR StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [n]
ERROR StatusLogger Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [d]
ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [thread]
ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [level]
ERROR StatusLogger Unrecognized conversion specifier [level] starting at position 35 in conversion pattern.

What else am i missing here as i keep getting above error even though my pattern doesn’t contain the default layout?
I was using log4j before migrating to log4j2.Din’t plan on migrating to log4j2 but as i had to upgrade spring and hibernate i started getting ERROR StatusLogger No Log4j2 configuration file found. That’s when i decided to migrate to log4j2.

Solution

First, lets list your dependencies and what they do:

  1. log4j-jcl provides an implementation for Apache Commons Logging to route those logging calls to Log4j 2.
  2. log4j-core is the Log4j 2 implementation.
  3. log4j-slf4j-impl routes logging calls using the SLF4J API to Log4j 2.
  4. log4j-api is the Log4j 2 API.
  5. log4j-1.2-api routes logging calls made using log4j 1.x to Log4j 2.
  6. log4j-to-slf4j routes logging calls from the Log4j 2 API to SLF4J.

In case it isn’t clear from the descriptions, item 6 is going to be a problem. First, you now have 2 implementations of the Log4j 2 API — log4j-core and log4j-to-slf4j. If log4j-to-slf4j were the one to «win» you would end up with logging going nowhere as the calls would bounce between Log4j and SLF4J and back again.

However, if these are in your dependencyManagement section of the the pom that would be a different story as all that does is declare which version of the jars you want to use.

As for the errors you are seeing, that happens because Log4j’s core plugins aren’t being loaded for some reason. That can happen if you are shading everything into a single jar and didn’t include Log4j’s Log4jPlugins.dat file.

Answered By — rgoers

Hi,

I wanted to start Minecraft server 1.13.2 — downloaded from official website.

After start with:

java -Xmx1024M -Xms1024M -jar c:!ServerMinecraftJavaserver.jar nogui

I received errors like below:

ERROR StatusLogger Unrecognized format specifier [d]
ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [thread]
ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [level]
ERROR StatusLogger Unrecognized conversion specifier [level] starting at position 35 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [logger]
ERROR StatusLogger Unrecognized conversion specifier [logger] starting at position 47 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [msg]
ERROR StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [n]
ERROR StatusLogger Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property 'org.apache.logging.log4j.simplelog.StatusLogger.level' to TRACE to show Log4j2 internal initialization logging.
ERROR StatusLogger Unrecognized format specifier [d]
ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [thread]
ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [level]
ERROR StatusLogger Unrecognized conversion specifier [level] starting at position 35 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [logger]
ERROR StatusLogger Unrecognized conversion specifier [logger] starting at position 47 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [msg]
ERROR StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [n]
ERROR StatusLogger Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.

What I can do with this error?

Already my Java in the latest version. I tried to start it on Win7 and WinServer — same result.

i was making before my own server without any problems.

Also I found that I need to delete one file in .jar file — but this file is not existing there.

Please help

Best regards

I’ve just changed on my project all log4j maven artifacts from 2.0.2 -> 2.1. When I deployed and started it on the Amazon EC2 Server got the following errors:
ERROR StatusLogger Unrecognized format specifier [d]
ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [thread]
ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [level]
ERROR StatusLogger Unrecognized conversion specifier [level] starting at position 35 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [logger]
ERROR StatusLogger Unrecognized conversion specifier [logger] starting at position 47 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [msg]
ERROR StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [n]
ERROR StatusLogger Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
ERROR StatusLogger Unrecognized format specifier [d]
ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [thread]
ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [level]
ERROR StatusLogger Unrecognized conversion specifier [level] starting at position 35 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [logger]
ERROR StatusLogger Unrecognized conversion specifier [logger] starting at position 47 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [msg]
ERROR StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [n]
ERROR StatusLogger Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.

I’ve nailed it down that it comes from the log4j-slfj-impl change. It is not major, since downgrading this artifact to 2.0.2 work just fine, but might be worth looking at.

openjdk version «1.8.0_242»

OpenJDK Runtime Environment (build 1.8.0_242-b08)

OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)

:/home/container$ java -Xms128M -Xmx4096M -jar server.jar

ERROR StatusLogger Unrecognized format specifier [d]

ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.

ERROR StatusLogger Unrecognized format specifier [thread]

ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.

ERROR StatusLogger Unrecognized format specifier [level]

ERROR StatusLogger Unrecognized conversion specifier [level] starting at position 35 in conversion pattern.

ERROR StatusLogger Unrecognized format specifier [logger]

ERROR StatusLogger Unrecognized conversion specifier [logger] starting at position 47 in conversion pattern.

ERROR StatusLogger Unrecognized format specifier [msg]

ERROR StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in conversion pattern.

ERROR StatusLogger Unrecognized format specifier [n]

ERROR StatusLogger Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.

ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property ‘org.apache.logging.log4j.simplelog.StatusLogger.level’ to TRACE to show Log4j2 internal initialization logging.

ERROR StatusLogger Unrecognized format specifier [d]

ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.

ERROR StatusLogger Unrecognized format specifier [thread]

ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.

ERROR StatusLogger Unrecognized format specifier [level]

ERROR StatusLogger Unrecognized conversion specifier [level] starting at position 35 in conversion pattern.

ERROR StatusLogger Unrecognized format specifier [logger]

ERROR StatusLogger Unrecognized conversion specifier [logger] starting at position 47 in conversion pattern.

ERROR StatusLogger Unrecognized format specifier [msg]

ERROR StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in conversion pattern.

ERROR StatusLogger Unrecognized format specifier [n]

ERROR StatusLogger Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.

[Hosting-Minecraft.com] Статус сервера изменён на ВЫКЛЮЧЕН

%d [%thread] %-5level %logger — %msg%nException in thread «main»

Сервер если что 1.12.2 с модами

harlins

2 / 2 / 3

Регистрация: 22.10.2013

Сообщений: 41

1

14.02.2016, 00:33. Показов 8535. Ответов 4

Метки нет (Все метки)


Ребята перешел к изучению логирования в java. Остановился на log4j
Пытаюсь создать простой проект чтобы проверить
Использую eclips последней версии.
Создал maven project c archetype quickstart
Создал конфигурационный файл log4j2.xml
В него поместил самый простой конфиг (взял из офф. сайта)

XML
1
2
3
4
5
6
7
8
9
10
11
12
13
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
        </Console>
    </Appenders>
    <Loggers>
        <Root level="error">
            <AppenderRef ref="Console" />
        </Root>
    </Loggers>
</Configuration>

Вот код тестового класса

Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package TestProject.test;
 
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args )
    {
        final Logger logger = LogManager.getLogger(App.class.getName());
        logger.error("Test Logger Messege");
    }
}

Но при запуске в консоль валит ошибку
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
23:21:45.182 [main] ERROR TestProject.test.App — Test Logger Messege
Не пойму почему он не видит конфиг файл

Добавлено через 3 минуты
Так ребята всем спасибо — уже разобрался. Простой нужно было в src/main создать папку resources и туда поместить конфигурационный файл.

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



Programming

Эксперт

94731 / 64177 / 26122

Регистрация: 12.04.2006

Сообщений: 116,782

14.02.2016, 00:33

4

39 / 28 / 8

Регистрация: 14.04.2012

Сообщений: 249

21.08.2016, 16:43

2

а без мавен можно как-то настроить?
у меня просит slf4j? нафиг он нужен



0



Эксперт Java

4087 / 3821 / 745

Регистрация: 18.05.2010

Сообщений: 9,331

Записей в блоге: 11

21.08.2016, 18:29

3

Цитата
Сообщение от kostrorod
Посмотреть сообщение

а без мавен можно как-то настроить?

Можно. Главное положить файл log4j2.xml в папку, которая попадёт в classpath приложения при запуске.

Цитата
Сообщение от kostrorod
Посмотреть сообщение

у меня просит slf4j?

Кто просит?



0



942 / 686 / 229

Регистрация: 28.04.2013

Сообщений: 1,924

21.08.2016, 18:34

4

Цитата
Сообщение от harlins
Посмотреть сообщение

Остановился на log4j

Первый?

Цитата
Сообщение от harlins
Посмотреть сообщение

Создал конфигурационный файл log4j2.xml

Где создал? Если log4j первый используете, то имя файла не верное.



0



kostrorod

39 / 28 / 8

Регистрация: 14.04.2012

Сообщений: 249

21.08.2016, 22:06

5

log4j2.xml положил в src Файл видит в idea ошибки пишет норм в консоль и файл.
Но если я запускаю собранный jar то выдаёт следующие ошибки

Кликните здесь для просмотра всего текста

Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
ERROR StatusLogger Unrecognized format specifier [d]
ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16
 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [thread]
ERROR StatusLogger Unrecognized conversion specifier [thread] starting at positi
on 25 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [level]
ERROR StatusLogger Unrecognized conversion specifier [level] starting at positio
n 35 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [logger]
ERROR StatusLogger Unrecognized conversion specifier [logger] starting at positi
on 47 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [msg]
ERROR StatusLogger Unrecognized conversion specifier [msg] starting at position
54 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [n]
ERROR StatusLogger Unrecognized conversion specifier [n] starting at position 56
 in conversion pattern.
ERROR StatusLogger No log4j2 configuration file found. Using default configurati
on: logging only errors to the console.
ERROR StatusLogger Unrecognized format specifier [d]
ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16
 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [thread]
ERROR StatusLogger Unrecognized conversion specifier [thread] starting at positi
on 25 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [level]
ERROR StatusLogger Unrecognized conversion specifier [level] starting at positio
n 35 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [logger]
ERROR StatusLogger Unrecognized conversion specifier [logger] starting at positi
on 47 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [msg]
ERROR StatusLogger Unrecognized conversion specifier [msg] starting at position
54 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [n]
ERROR StatusLogger Unrecognized conversion specifier [n] starting at position 56
 in conversion pattern.
%d [%thread] %-5level %logger - %msg%n

log4j2.xml

Кликните здесь для просмотра всего текста

XML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="ERROR">
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{dd-MM-yyyy HH:mm:ss} %p: %msg -- %l %n"/>
        </Console>
        <!-- Файловый аппендер -->
        <File name="file" fileName="d:backup.log">
            <PatternLayout>
                <Pattern>%d{dd-MM-yyyy HH:mm:ss} [%-5p][%-20c{1}] [%-20M:%L] - %msg%n</Pattern>
            </PatternLayout>
        </File>
    </Appenders>
    <Loggers>
        <Root level="error">
            <AppenderRef ref="Console"/>
            <AppenderRef ref="file"/>
        </Root>
    </Loggers>
</Configuration>

Добавлено через 2 часа 36 минут
ошибку исправил версией apache-log4j-2.3
видимо в версии apache-log4j-2.6.2 баг. Имейте в виду.



0



Понравилась статья? Поделить с друзьями:
  • Error status unknown storage type 0xc0040009
  • Error status unknown storage section type 0xc003000c
  • Error status too large 0xc0040004
  • Error status stor life exhaust 0xc003001d
  • Error status stop life exhaust 0xc003001d