Help pattern for multiline logs

What pattern should I use to retrieve correctly multi-lines logs ?

Normally I use :

  file {
    path => "/var/log/appslogs/**/*.log"
    start_position => "beginning"
    sincedb_path => "/dev/null"
	codec => multiline {
	  pattern => "^\s"
	  what => "previous"
    type => "app"

Here is an exemple of logs (with and without error) :

2023-02-09 00:00:03 [DEBUG] org.apache.activemq.util.ThreadPoolUtils:54 -> Forcing shutdown of ExecutorService: java.util.concurrent.ThreadPoolExecutor@646bc5f[Running, pool size = 1, active threads = 0, queued tasks = 0, completed tasks = 1] 2
2023-02-09 00:00:03 [ERROR] org.apache.camel.component.jms.DefaultJmsMessageListenerContainer:934 -> Could not refresh JMS Connection for destination 'EVENT-BUS-GET-ECHO-V1-eures-jv-batch-01' - retrying using FixedBackOff{interval=5000, currentAttempts=9124, maxAttempts=unlimited}. Cause: Error while attempting to add new Connection to the pool; nested exception is javax.jms.JMSException: Could not connect to broker URL: tcp://eures-jms:31314. Reason: eures-jms
javax.jms.JMSException: Error while attempting to add new Connection to the pool
	at org.apache.activemq.jms.pool.PooledConnectionFactory.createJmsException(
	at org.apache.activemq.jms.pool.PooledConnectionFactory.createConnection(
	at org.apache.activemq.jms.pool.PooledConnectionFactory.createConnection(
	at org.springframework.jms.listener.AbstractJmsListeningContainer.createSharedConnection(
	at org.springframework.jms.listener.AbstractJmsListeningContainer.refreshSharedConnection(
	at org.springframework.jms.listener.DefaultMessageListenerContainer.refreshConnectionUntilSuccessful(
	at org.springframework.jms.listener.DefaultMessageListenerContainer.recoverAfterListenerSetupFailure(
	at org.springframework.jms.listener.DefaultMessageListenerContainer$
	at java.util.concurrent.ThreadPoolExecutor.runWorker(
	at java.util.concurrent.ThreadPoolExecutor$
	at 3

But it's not working for this type of error.

Here is my grok pattern if you need it :

%{TIMESTAMP_ISO8601:time} \[%{LOGLEVEL:log_level}\] %{GREEDYDATA:message_of_log}

You should use the date as the multiline pattern, something like this:

pattern => "^\d{4}-\d{2}-\d{2}"

Every line that starts with a date will start the multiline, if a line does not start with a date it will e added to the previous multiline log.

It's not working :

You can see that multiple logs are retrieved as one :confused:

Yeah, I thought you have the negate already in your multiline configuration.

You need to have negate => true.

Try this:

        codec => multiline {
            pattern => "^\d{4}-\d{2}-\d{2}"
            negate => true
            what => "previous"

Thanks, it work perfectly :blush:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.