Reconfiguring gerrit logging

4,663 views
Skip to first unread message

Dariusz Luksza

unread,
Oct 2, 2013, 9:48:35 AM10/2/13
to repo-discuss
Is there any possibility to tweak logging configuration of Gerrit?

Currently the only possibility that I can see is to extract
gerrit-server.jar from gerrit.war, then extract and modify
log4j.properties from gerrit-server.war. After that repack everything
again. This is not user friendly approach.

Maybe I missed something?

--
Best regards

GSM: +49 017 445 41235
Blog: http://luksza.org
LinkedIn: http://www.linkedin.com/in/dariuszluksza

Thomas Swindells (tswindel)

unread,
Oct 2, 2013, 10:00:19 AM10/2/13
to Dariusz Luksza, repo-discuss
It depends on how you are deploying Gerrit, but generally you can just override a jars log4j.properties by having another version of the file someone on the classpath.
As long as that file is found first it will be used - generally ./etc will be the first entry of the classpath so any files in there will override what is on disk.
If it is a war being deployed within tomcat there may be other ways to do this, and I haven't double checked the actual Gerrit launch scripts.

Thomas
> --
> --
> To unsubscribe, email repo-discuss...@googlegroups.com
> More info at http://groups.google.com/group/repo-discuss?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Repo and Gerrit Discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to repo-discuss...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Luca Milanesio

unread,
Oct 2, 2013, 10:14:33 AM10/2/13
to Dariusz Luksza, repo-discuss Discussion, Thomas Swindells (tswindel)
we typically put it under /etc and it works fine.

P.S. Remember to customise your classpath, otherwise it will not take it out of the box.

Luca.

Shawn Pearce

unread,
Oct 2, 2013, 12:51:19 PM10/2/13
to Luca Milanesio, Dariusz Luksza, repo-discuss Discussion, Thomas Swindells (tswindel)
Its not currently customizable, but maybe someone wants to upload a
change to add a variable in gerrit.config that points to a local
log4j.properties file the server will load and honor, or just teach
the server to look for the file in etc/, or something... ? :-)

For gerrit-review we have a way to pass the logging configuration from
outside of the binary. Most direct equivalent would be to put the
properties directly into gerrit.config e.g.:

[log "channel.name"]
level = DEBUG

But its probably better to just have etc/log4j.properties be
automatically recognized and used by the server instead of the bundled
one. Or combined with the bundled one, since we silence some noisy
channels by default.

Dariusz Luksza

unread,
Oct 2, 2013, 1:07:23 PM10/2/13
to Shawn Pearce, Luca Milanesio, repo-discuss, Thomas Swindells (tswindel)

Separate variable in gerrit.config sounds like a good idea for setting up internal gerrit logging system.

But what about providing initial configuration for pluggins? eg. if one plugin wants to log to separate file?

David Ostrovsky

unread,
Oct 3, 2013, 4:43:17 AM10/3/13
to repo-d...@googlegroups.com, Luca Milanesio, Dariusz Luksza, Thomas Swindells (tswindel), repo-discuss


Am Mittwoch, 2. Oktober 2013 18:51:19 UTC+2 schrieb Shawn Pearce:
Its not currently customizable, but maybe someone wants to upload a
change to add a variable in gerrit.config that points to a local
log4j.properties file the server will load and honor, or just teach
the server to look for the file in etc/, or something... ? :-)

Dariusz Luksza

unread,
Oct 9, 2013, 10:42:10 AM10/9/13
to David Ostrovsky, repo-discuss, Luca Milanesio, Thomas Swindells (tswindel)
We just discovered that 'javaOptions = -Dlog4j.configuration' works
when is NOT run as a service.

It seams that there is a difference in log system initialization
depends on startup mode. When gerrit is run "interactive" mode then
-Dlog4j.configuration is taken into account, but when it is started as
a service then configuration is overwritten. Does it rings any bells
to you?

--
Best regards

GSM: +49 017 445 41235
Blog: http://luksza.org
LinkedIn: http://linkedin.com/in/dariuszluksza

Shawn Pearce

unread,
Oct 9, 2013, 11:16:13 AM10/9/13
to Dariusz Luksza, David Ostrovsky, repo-discuss, Luca Milanesio, Thomas Swindells (tswindel)
On Wed, Oct 9, 2013 at 7:42 AM, Dariusz Luksza <dariusz...@gmail.com> wrote:
> On Thu, Oct 3, 2013 at 10:43 AM, David Ostrovsky
> <david.o...@gmail.com> wrote:
>>
>>
>> Am Mittwoch, 2. Oktober 2013 18:51:19 UTC+2 schrieb Shawn Pearce:
>>>
>>> Its not currently customizable, but maybe someone wants to upload a
>>> change to add a variable in gerrit.config that points to a local
>>> log4j.properties file the server will load and honor, or just teach
>>> the server to look for the file in etc/, or something... ? :-)
>>
>>
>> https://gerrit-review.googlesource.com/50443
>
> We just discovered that 'javaOptions = -Dlog4j.configuration' works
> when is NOT run as a service.
>
> It seams that there is a difference in log system initialization
> depends on startup mode. When gerrit is run "interactive" mode then
> -Dlog4j.configuration is taken into account, but when it is started as
> a service then configuration is overwritten. Does it rings any bells
> to you?

Yes, sadly. Look at ErrorLogFile line 76. This code is called unless
you pass --console-log on the command line. It reconfigures the root
logger by stripping all appenders and adding its own appender that
handles rotation. :-(

Dariusz Luksza

unread,
Oct 9, 2013, 12:08:55 PM10/9/13
to Shawn Pearce, David Ostrovsky, repo-discuss, Luca Milanesio, Thomas Swindells (tswindel)
On Wed, Oct 9, 2013 at 5:31 PM, Dariusz Luksza <dariusz...@gmail.com> wrote:
> I'm currently testing my fix for ErrorLogFile, when property
> log4j.configuration is set then we will skip this log configuration.
>
> Will push this fix in couple of minutes to stable-2.6

Here it is:

https://gerrit-review.googlesource.com/50661

Dariusz Luksza

unread,
Oct 9, 2013, 11:31:09 AM10/9/13
to Shawn Pearce, David Ostrovsky, repo-discuss, Luca Milanesio, Thomas Swindells (tswindel)
On Wed, Oct 9, 2013 at 5:16 PM, Shawn Pearce <s...@google.com> wrote:
I'm currently testing my fix for ErrorLogFile, when property
log4j.configuration is set then we will skip this log configuration.

Will push this fix in couple of minutes to stable-2.6

Reply all
Reply to author
Forward
0 new messages