parzival
parzival

Reputation: 1626

Adding my own appender through log4j configuration file

I made my own appender :

class MyAppender : public AppenderSkeleton
{...
void MyAppender ::append(const spi::LoggingEventPtr& event, Pool& p)
{
    LogString log;
    log4cxx::helpers::Pool pool;
    printf("test\n");
    getLayout()->format(log, event, pool);
    ...
}
...
 boolean requiresLayout(){return false; }
...
}

Also I added it through log4j configuration file :

log4j.appender.MYAPPND=org.apache.log4j.MyAppender 
log4j.appender.MYAPPND.layout=org.apache.log4j.PatternLayout
log4j.appender.MYAPPND.layout.ConversionPattern=%d{ISO8601} %d{%Z} [%-5p] [%t] [%c] [%C{1}.%M(%L)] - %m%n

log4j.logger.file.name = DEBUG, MYAPPND

It works nice till getLayout()->format(log, event, pool) {segmentation fault}. Any help ?

Upvotes: 0

Views: 199

Answers (1)

parzival
parzival

Reputation: 1626

I edited my question and answer is there now (all code needs always to be printed if it is possible). So, problem was into override method requiresLayout. It returns false, and true is right solution.

Upvotes: 1

Related Questions