custom log file size not restricted

classic Classic list List threaded Threaded
26 messages Options
12
Reply | Threaded
Open this post in threaded view
|

custom log file size not restricted

jyothi
Hi,

I have configured for a custom log in pax logging in Karaf as follows and
found the size of the custom log is not restricted to 1 MB and increasing.
Can you please let us know what could be the issue? Thanks in advance

log4j.appender.custom = org.apache.log4j.RollingFileAppender
log4j.appender.custom.append = true
log4j.appender.custom.file = ${karaf.data}/log/custom.log
log4j.appender.custom.layout = org.apache.log4j.PatternLayout
log4j.appender.custom.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss Z} |
%-5.5p | %t | %c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} |
%m%n
log4j.appender.custom.maxBackupIndex = 10
log4j.appender.custom.maxFileSize = 1MB




--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: custom log file size not restricted

jbonofre
Hi,

It should work (it's what we are using without problem for "out" appender).

I guess you added this appender in the logger (rootLogger or specific logger)
right ?

Can you try to remove extra spaces around '=' ?

Regards
JB

On 12/13/2017 07:05 AM, jyothi wrote:

> Hi,
>
> I have configured for a custom log in pax logging in Karaf as follows and
> found the size of the custom log is not restricted to 1 MB and increasing.
> Can you please let us know what could be the issue? Thanks in advance
>
> log4j.appender.custom = org.apache.log4j.RollingFileAppender
> log4j.appender.custom.append = true
> log4j.appender.custom.file = ${karaf.data}/log/custom.log
> log4j.appender.custom.layout = org.apache.log4j.PatternLayout
> log4j.appender.custom.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss Z} |
> %-5.5p | %t | %c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} |
> %m%n
> log4j.appender.custom.maxBackupIndex = 10
> log4j.appender.custom.maxFileSize = 1MB
>
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: custom log file size not restricted

jyothi
Hi JB,

Thanks for the quick response!!

Regarding spaces, that is generated one using config:property-append from
Karaf console. I will try to remove spaces and check if it works!!

Please find my complete pax logging config and I didn't added anything to
rootLogger. Do I need to add custom to the log4j.rootLogger?

# Root logger
log4j.rootLogger = INFO, out, osgi:*
log4j.throwableRenderer=org.apache.log4j.OsgiThrowableRenderer

# Security audit logger
log4j.logger.org.apache.karaf.jaas.modules.audit=INFO, audit
log4j.additivity.org.apache.karaf.jaas.modules.audit=false

# CONSOLE appender not used by default
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} | %-5.5p |
%-16.16t | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} -
%X{bundle.version} | %m%n

# File appender
log4j.appender.out=org.apache.log4j.RollingFileAppender
log4j.appender.out.layout=org.apache.log4j.PatternLayout
log4j.appender.out.layout.ConversionPattern = %d{ISO8601} | %-5.5p | %t |
%c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n
log4j.appender.out.file=${karaf.data}/log/karaf.log
log4j.appender.out.append=true
log4j.appender.out.maxFileSize=1MB
log4j.appender.out.maxBackupIndex=10


log4j.appender.custom = org.apache.log4j.RollingFileAppender
log4j.appender.custom.append = true
log4j.appender.custom.file = ${karaf.data}/log/userLog.log
log4j.appender.custom.layout = org.apache.log4j.PatternLayout
log4j.appender.custom.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss Z} |
%-5.5p | %t | %c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} |
%m%n
log4j.appender.custom.maxBackupIndex = 10
log4j.appender.custom.maxFileSize = 1MB

log4j.logger.com.globalhealth.referralnet.agent.exception = INFO,custom
log4j.logger.com.globalhealth.referralnet.agent.logger = INFO,custom
log4j.logger.com.globalhealth.referralnet.agent.upgrade.impl.RNAUpgradeUserLogger
= INFO,custom






--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: custom log file size not restricted

jbonofre
Hi,

your configuration looks good to me.

Yes, please try to remove extra space first.

By the way, what's the Karaf version (I guess 4.0.x regarding your cfg file) ?
As reminder, Karaf 4.0.x uses log4j 1.x configuration style, and from Karaf
4.1.x, we are using log4j 2.x style.

Regards
JB

On 12/13/2017 12:42 PM, jyothi wrote:

> Hi JB,
>
> Thanks for the quick response!!
>
> Regarding spaces, that is generated one using config:property-append from
> Karaf console. I will try to remove spaces and check if it works!!
>
> Please find my complete pax logging config and I didn't added anything to
> rootLogger. Do I need to add custom to the log4j.rootLogger?
>
> # Root logger
> log4j.rootLogger = INFO, out, osgi:*
> log4j.throwableRenderer=org.apache.log4j.OsgiThrowableRenderer
>
> # Security audit logger
> log4j.logger.org.apache.karaf.jaas.modules.audit=INFO, audit
> log4j.additivity.org.apache.karaf.jaas.modules.audit=false
>
> # CONSOLE appender not used by default
> log4j.appender.stdout=org.apache.log4j.ConsoleAppender
> log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
> log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} | %-5.5p |
> %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} -
> %X{bundle.version} | %m%n
>
> # File appender
> log4j.appender.out=org.apache.log4j.RollingFileAppender
> log4j.appender.out.layout=org.apache.log4j.PatternLayout
> log4j.appender.out.layout.ConversionPattern = %d{ISO8601} | %-5.5p | %t |
> %c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n
> log4j.appender.out.file=${karaf.data}/log/karaf.log
> log4j.appender.out.append=true
> log4j.appender.out.maxFileSize=1MB
> log4j.appender.out.maxBackupIndex=10
>
>
> log4j.appender.custom = org.apache.log4j.RollingFileAppender
> log4j.appender.custom.append = true
> log4j.appender.custom.file = ${karaf.data}/log/userLog.log
> log4j.appender.custom.layout = org.apache.log4j.PatternLayout
> log4j.appender.custom.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss Z} |
> %-5.5p | %t | %c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} |
> %m%n
> log4j.appender.custom.maxBackupIndex = 10
> log4j.appender.custom.maxFileSize = 1MB
>
> log4j.logger.com.globalhealth.referralnet.agent.exception = INFO,custom
> log4j.logger.com.globalhealth.referralnet.agent.logger = INFO,custom
> log4j.logger.com.globalhealth.referralnet.agent.upgrade.impl.RNAUpgradeUserLogger
> = INFO,custom
>
>
>
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: custom log file size not restricted

jyothi
Hi JB!!

We are using karaf-4.0.5.

Thanks & Regards,
Jyothi.



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: custom log file size not restricted

jyothi
Hi JB!!

When we removed spaces it worked!! Thanks for that.

But the config file content is generated using below script or ConfigMBean
update method.Can you please tell how can we remove the spaces without
manual action?

Ex:
config:edit org.ops4j.pax.logging
config:property-set log4j.appender.custom.file
'${karaf.data}/log/custom.log'
config:property-set log4j.appender.custom.append true
config:property-set log4j.appender.custom.maxFileSize 1MB
config:property-set log4j.appender.custom.maxBackupIndex 10
config:update

Thanks & Regards,
Jyothi





--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: custom log file size not restricted

jbonofre
Hi Jyothi

Actually, there's two things:

1. Pax Logging should trim extra space
2. The config:* commands should not add extra spaces ;)

So, let me check for both ;)

Regards
JB

On 12/15/2017 08:26 AM, jyothi wrote:

> Hi JB!!
>
> When we removed spaces it worked!! Thanks for that.
>
> But the config file content is generated using below script or ConfigMBean
> update method.Can you please tell how can we remove the spaces without
> manual action?
>
> Ex:
> config:edit org.ops4j.pax.logging
> config:property-set log4j.appender.custom.file
> '${karaf.data}/log/custom.log'
> config:property-set log4j.appender.custom.append true
> config:property-set log4j.appender.custom.maxFileSize 1MB
> config:property-set log4j.appender.custom.maxBackupIndex 10
> config:update
>
> Thanks & Regards,
> Jyothi
>
>
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: custom log file size not restricted

jyothi
Hi JB!!

Can we know if you got a chance to check the spaces issue in Pax Logging?

Thanks & Regards,
Jyothi.




--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: custom log file size not restricted

jbonofre
Hi,

not yet, I will create the Jira and work on it today.

Sorry about the delay.

Regards
JB

On 12/22/2017 06:09 AM, jyothi wrote:

> Hi JB!!
>
> Can we know if you got a chance to check the spaces issue in Pax Logging?
>
> Thanks & Regards,
> Jyothi.
>
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: custom log file size not restricted

jyothi
Hi JB!!

Sorry for disturbing you frequently on this !!

Please let me know if I can track of this JIRA issue?

Regards,
Jyothi.



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: custom log file size not restricted

jbonofre
Hi Jyothi,

I have a local branch with the fix in Pax Logging. I will prepare a release to
be able to update in Karaf.

I keep you posted.

Regards
JB

On 01/04/2018 05:30 AM, jyothi wrote:

> Hi JB!!
>
> Sorry for disturbing you frequently on this !!
>
> Please let me know if I can track of this JIRA issue?
>
> Regards,
> Jyothi.
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: custom log file size not restricted

jyothi
Thank you so much JB!!



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: custom log file size not restricted

jbonofre
In reply to this post by jyothi
Hi Jyothi,

I just tested with Karaf 4.0.11-SNAPSHOT and it works fine (using or not space).

Let me try with Karaf 4.0.5.

Regards
JB

On 12/14/2017 06:04 AM, jyothi wrote:

> Hi JB!!
>
> We are using karaf-4.0.5.
>
> Thanks & Regards,
> Jyothi.
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: custom log file size not restricted

jbonofre
Hmmm, it works fine on my box using 4.0.5 using the following config:

log4j.rootLogger=DEBUG, out, custom, osgi:*

...

log4j.appender.custom = org.apache.log4j.RollingFileAppender
log4j.appender.custom.append = true
log4j.appender.custom.file = ${karaf.data}/log/custom.log
log4j.appender.custom.layout = org.apache.log4j.PatternLayout
log4j.appender.custom.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss Z} |
%-5.5p | %t | %c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} |
%m%n
log4j.appender.custom.maxBackupIndex = 10
log4j.appender.custom.maxFileSize = 1KB

Dump question: when you changed org.ops4j.pax.logging configuration (via the
shell commands), did you restart the pax-logging service or Karaf ?

Regards
JB

On 01/09/2018 04:27 PM, Jean-Baptiste Onofré wrote:

> Hi Jyothi,
>
> I just tested with Karaf 4.0.11-SNAPSHOT and it works fine (using or not space).
>
> Let me try with Karaf 4.0.5.
>
> Regards
> JB
>
> On 12/14/2017 06:04 AM, jyothi wrote:
>> Hi JB!!
>>
>> We are using karaf-4.0.5.
>>
>> Thanks & Regards,
>> Jyothi.
>>
>>
>>
>> --
>> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>>
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: custom log file size not restricted

jyothi
Hi,

 I didn't add custom to rootLogger.Do I need to add it?

Yes I restarted Karaf after the changes and this issue happened only on two
machines and not reproduced in other machines.

Thanks,
Jyothi.



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: custom log file size not restricted

jbonofre
You need to add the appender to a logger (rootLogger or specific one).

Can you share how you "call" the appender ?

Regards
JB

On 01/10/2018 01:29 AM, jyothi wrote:

> Hi,
>
>   I didn't add custom to rootLogger.Do I need to add it?
>
> Yes I restarted Karaf after the changes and this issue happened only on two
> machines and not reproduced in other machines.
>
> Thanks,
> Jyothi.
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: custom log file size not restricted

jyothi
Sorry for the delay.. Back from vacation !!

Configuring appender in this way in pom and importing org.apache.log4j in
<Import-Package>. Please let me know if I answered you properly

   <dependency>
     <groupId>org.ops4j.pax.logging</groupId>
     <artifactId>pax-logging-service</artifactId>
     <version>1.8.4</version>
     <scope>provided</scope>
   </dependency>
   <dependency>
     <groupId>org.ops4j.pax.logging</groupId>
     <artifactId>pax-logging-api</artifactId>
     <version>1.8.4</version>
     <scope>provided</scope>
   </dependency>



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: custom log file size not restricted

jyothi
Hi JB,

Please find the attached image, where user log is not restricted to 1MB with
below config in Pax Logging. Can you please suggest us on this if spaces are
not an issue?

log4j.appender.custom = org.apache.log4j.RollingFileAppender
log4j.appender.custom.append = true
log4j.appender.custom.file = ${karaf.data}/log/userLog.log
log4j.appender.custom.layout = org.apache.log4j.PatternLayout
log4j.appender.custom.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss Z} |
%-5.5p | %t | %c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} |
%m%n
log4j.appender.custom.maxBackupIndex = 10
log4j.appender.custom.maxFileSize = 1MB
log4j.logger.com.exception = INFO,custom
log4j.logger.com.logger = INFO,custom

Thanks & Regards,
Jyothi
<http://karaf.922171.n3.nabble.com/file/t497873/304e50db-7e19-4e90-9e02-79d3f85acb26.jpg>




--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: custom log file size not restricted

jbonofre
Can you send the complete org.ops4j.pax.logging.cfg ?

What's your OS ?

Thanks,
Regards
JB

On 01/30/2018 06:01 AM, jyothi wrote:

> Hi JB,
>
> Please find the attached image, where user log is not restricted to 1MB with
> below config in Pax Logging. Can you please suggest us on this if spaces are
> not an issue?
>
> log4j.appender.custom = org.apache.log4j.RollingFileAppender
> log4j.appender.custom.append = true
> log4j.appender.custom.file = ${karaf.data}/log/userLog.log
> log4j.appender.custom.layout = org.apache.log4j.PatternLayout
> log4j.appender.custom.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss Z} |
> %-5.5p | %t | %c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} |
> %m%n
> log4j.appender.custom.maxBackupIndex = 10
> log4j.appender.custom.maxFileSize = 1MB
> log4j.logger.com.exception = INFO,custom
> log4j.logger.com.logger = INFO,custom
>
> Thanks & Regards,
> Jyothi
> <http://karaf.922171.n3.nabble.com/file/t497873/304e50db-7e19-4e90-9e02-79d3f85acb26.jpg>
>
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: custom log file size not restricted

jyothi
Hi JB!!

Mailed you the pax logging file and this issue is reproducible in Windows
environment.

Regards,
Jyothi



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
12