简体   繁体   中英

Wildfly log date on every stack trace line

I use wildfly and have a problem with the output of the FILE log handler. It prints every line of an error of a stack trace with the full formatted form. Here it is a cutted example:

12:13:11,238 ERROR [stderr] (default task-48) org.apache.shiro.authc.UnknownAccountException: Realm [XXX.account.library.security.shiro.ClientApplicationRealm@14896aa1] was unable to find account data for the submitted AuthenticationToken [org.apache.shiro.authc.UsernamePasswordToken - XXX, rememberMe=false].
12:13:11,238 ERROR [stderr] (default task-48)   at org.apache.shiro.authc.pam.ModularRealmAuthenticator.doSingleRealmAuthentication(ModularRealmAuthenticator.java:184)
12:13:11,238 ERROR [stderr] (default task-48)   at org.apache.shiro.authc.pam.ModularRealmAuthenticator.doAuthenticate(ModularRealmAuthenticator.java:267)
12:13:11,238 ERROR [stderr] (default task-48)   at org.apache.shiro.authc.AbstractAuthenticator.authenticate(AbstractAuthenticator.java:198)
12:13:11,238 ERROR [stderr] (default task-48)   at org.apache.shiro.mgt.AuthenticatingSecurityManager.authenticate(AuthenticatingSecurityManager.java:106)
...

I just wanted to have the the line with "12:13:11,238 ERROR [stderr] (default task-48)" once at the beginning and every party of the stack trace beginning with "at" not as a new log line interpreted as a new log line.

I have an additional SMTP log handler and there is the same problem. So it sends an email for every line of the stack trace and not one email per error or exception.

Thanks in advance.

This looks a lot like someone has left something like the following in their code:

  try {
      // do something that throws an exception
  } catch (SomeException e) {
      e.printStackTrace();
  }

I would be really surprised if this was in Apache Shiro code.

In general it's a good idea to use one of the many logging libraries around and report it like:

  } catch (SomeException e) {
      logger.error("Something failed", e);
  }

In some cases if you're using a console appender or handler defined in a logging configuration within your deployment this may also cause this. The reason being is that WildFly wraps both System.out and System.err in a logger. This would result in the format you're seeing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM