James Hutton | 19 Dec 14:10 2014
Picon

Using markers or ThreadContext to select logger via slf4j

I have some libraries that leverage slf4j for logging (can't change it)
however my application leverages log4j2 and the slf4j-log4j2 bridge.  I was
wondering if there is a way I can at the beginning of the request flow set
a value in the ThreadContext or something so that the slf4j loggers will
route to a specific log4j2 logger instead of the root logger.  Is this
possible?

Thanks,
James
Mariano Gonzalez | 19 Dec 14:01 2014
Picon

Race condition stopping context

Hello,

I have an application in which I'm using all async loggers. When I stop the
LoggerContext, there're still some events waiting in disruptor's buffer and
when it tries to execute them the context is already closed and thus those
events are lost.

Is there some kind of hook, callback or whatever I can use so that when the
context is stopped:

   - the loggers stop accepting new messages
   - the context waits for disruptor's buffer to be empty before actually
   stopping

Thanks
Ben Stover | 19 Dec 11:43 2014
Picon

How to write encrypted (!) lines to logfile ?

As far as I know the standard way of writing log output to logfiles is as plain human readable text.

Is there a way to configure log4j to enrypt lines before writing?
Or (re-)encrypt whole logfile after writing?

The encryption should NOT take place IN the writing application but be configured inside log4j configuration.

Ben
Alireza Fattahi | 17 Dec 15:32 2014

rThrowable does not call getLocalizedMessage

Hi,
It seems that the %rThrowable{full} pattern will not use getLocalizedMessage by default, while the
%Throwable{full} will out put it.
The rThrowable{short.localizedMessage} is nor working
My pattern is:
<property name="consolelayoutPattern">%-5p %-30.30c{2} %m%n%rThrowable{full}</property>

Do you think the default behavior of rThrowable must be changed ? ~Regards,
~~Alireza Fattahi
Alireza Fattahi | 15 Dec 05:50 2014

Log4j2 web look up cannot access servletcontext attribute

We are using Tomcat 7.0.54. 
The web.xml:
 <context-param>        <param-name>log4jContextName</param-name>       
<param-value>SabaLog4jContext</param-value>    </context-param>
There is sample servlet which starts on load
        <servlet>            <servlet-name>startUp</servlet-name>           
<servlet-class>foo.StartupServlet</servlet-class>           
<load-on-startup>1</load-on-startup>        </servlet>
The StartupServlet simple as:
    public class StartupServlet extends HttpServlet {         <at> Override        public void init()
throws ServletException {            getServletContext().setAttribute("test", "ATest");   
        super.init();        }        }
The log4j2 can not access the `test` attribute with `${web:attr.test}` and I got the warning as:
    INFO: org.apache.logging.log4j.web.WebLookup unable to resolve key 'test'
It seems that Log4j2 works fine but the problem is that it starts before my Startup. I tried to use a
`servletContextListener` class but no luck.
I also tried to disable Log4jAutoInitialization in web.xml and manually start set them as below.
     <listener>       
<listener-class>org.apache.logging.log4j.web.Log4jServletContextListener</listener-class> 
  </listener>         <filter>       <filter-name>log4jServletFilter</filter-name>   
   <filter-class>org.apache.logging.log4j.web.Log4jServletFilter</filter-class>   
</filter>    <filter-mapping>       <filter-name>log4jServletFilter</filter-name>     
 <url-pattern>/*</url-pattern>       <dispatcher>REQUEST</dispatcher>     
<dispatcher>FORWARD</dispatcher>      <dispatcher>INCLUDE</dispatcher>     
<dispatcher>ERROR</dispatcher>    </filter-mapping>

But no luck:(
The log4j2.xml is as below:
    <property name="baseFolder">${web:rootDir}/../logs/${web:test}</property>
So how can setup my web.xml so that my code execute before Log4j context.
(Continue reading)

Mariano Gonzalez | 2 Dec 18:46 2014
Picon

ArrayIndexOutOfBoundsException with RollingFileApender

Hello,

I'm progamatically creating an appender with the following code:

private static final String PATTERN_LAYOUT = "%-5p %d [%t] %c: %m%n";

private RollingFileAppender createRollingFileAppender(String logFilePath,
String filePattern, String appenderName, Configuration configuration)
{
    TriggeringPolicy triggeringPolicy =
TimeBasedTriggeringPolicy.createPolicy("1", "true");
    RolloverStrategy rolloverStrategy =
DefaultRolloverStrategy.createStrategy("30", "1", null,
String.valueOf(Deflater.NO_COMPRESSION), configuration);

    return RollingFileAppender.createAppender(logFilePath,
      logFilePath + filePattern,
      "true",
      appenderName,
      "true",
      null, null,
      triggeringPolicy,
      rolloverStrategy,
      createLayout(configuration),
      null, null, null, null,
      configuration);
}

private Layout<? extends Serializable> createLayout(Configuration
configuration)
(Continue reading)

Yair Ogen (yaogen | 30 Nov 09:29 2014
Picon

includeLocation = true by default in LoggerConfig

I am using log4j2.1. any reason this flag is set to true by default? It is very expensive (cpu wise) and AFAIK
is something usually set by the pattern (i.e. display source file and source line).

J.Hoffmann | 25 Nov 17:49 2014
Picon
Picon

What happened to Telnet-Appender in log4j2?

Hi everybody,

We have used the Telnet-Appender with log4j.
When migrating to log4j2 I have seen, that it seem to doesn't exist anymore
in log4j2?
I was even not able to find any information at Apache. What happend to
Telnet Appender?

Thanks for reply.

J.Hoffmann
Stephan Druskat | 24 Nov 10:58 2014
Picon
Picon

Using log4j2 2.1 over slf4j 1.7.7 in Eclipse RCP

Dear List,

I'm developing an Eclipse RCP based on Eclipse 3.7.2 (Indigo).

I'd like to use log4j2 (2.1) over slf4j 1.7.7, but I'm having trouble
getting it to work. I have done the following to add log4j2 and slf4j to
my application.

- I've built a p2 repo including slf4j.api_1.7.7.jar,
org.apache.logging.log4j.core_2.1.0.jar,
org.apache.logging.log4j.api_2.1.0.jar,
org.apache.logging.log4j.slf4j-impl_2.1.0.jar.

- I've consumed this p2 repo in my target platform + added it to the
parent POM of my project.

- I've added all 4 plugins to my Eclipse plugin project as dependencies
in MANIFEST.MF.

- I've created a file log4j2.xml in the project root in my Eclipse
plugin. Content below.

- I've added a private static final Logger logger =
LoggerFactory.getLogger(MyClass.class) field to MyClass

- In MyClass, I've called logger.error("Hi from logger").

However, when I run my application, I'm getting an error message: ERROR
StatusLogger Log4j2 could not find a logging implementation. Please add
log4j-core to the classpath. Using SimpleLogger to log to the console...
(Continue reading)

Dave Westerman | 21 Nov 17:18 2014
Picon

Commit errors using log4j2 JDBCAppender with DB2 in WebSphere Liberty Profile

I am trying to use the log4j2 JDBCAppender in my JEE application in 
WebSphere Liberty Profile with a DB2 DataSource. I'm wondering if I have a 
configuration error, because I am seeing the following error in my log:

Caused by: java.sql.SQLException: DSRA9350E: Operation Connection.commit 
is not allowed during a global transaction. 
    at 
com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.commit(WSJdbcConnection.java:778) 

    at

org.apache.logging.log4j.core.appender.db.jdbc.JdbcDatabaseManager.commitAndClose(JdbcDatabaseManager.java:139) 

    ... 84 more 
2014-11-20 20:23:33,663 ERROR An exception occurred processing Appender 
OneViewPrimaryLogDatabase 
org.apache.logging.log4j.core.appender.AppenderLoggingException: Failed to 
commit transaction logging event or flushing buffer. 

Here is my log4j config data:

    <JDBC name="OneViewPrimaryLogDatabase" tableName="IONEVIEW.LOG"> 
        <DataSource jndiName="jdbc/OneViewPrimaryLogDataSource" /> 
        <Column name="LOGDATE" isEventTimestamp="true" /> 
        <Column name="LOGGER" pattern="%logger" isUnicode="false" /> 
        <Column name="LOGLEVEL" pattern="%level" isUnicode="false" /> 
        <Column name="MESSAGE" pattern="%message" isUnicode="false" /> 
    </JDBC> 

And here is my DataSource config from WLP:
(Continue reading)

Tomek Sztelak | 21 Nov 10:34 2014
Picon

Log4j 2.1 and compilation memory usage

Hello

We just updated log4j from 2.0-beta9 to 2.1 and memory consumtion during
compilation of  our application increased about 300-400MB causing
OutOfMemory on same machines.
Any idea what can cause this?

Best regards.

Gmane