Re: GCP logging

2020-01-24 Thread Francesco Chicchiriccò
Thanks Ralph, log4j2-logstash-layout looks great, I'll give it a try.
Regards.

On 2020/01/24 16:10:39, Ralph Goers  wrote: 
> At first glance I would think that just as we have a GELF Layout we would 
> want a separate StackdriverJsonLayout rather than trying to force it into the 
> generic JsonLayout. 
> 
> I should also point out that the author of the LogstashLayout [1] is pursuing 
> contributing it to Log4j 2, which seems like a viable alternative to 
> JsonLayout.
> 
> [1] https://github.com/vy/log4j2-logstash-layout 
> 
> 
> Ralph
> 
> > On Jan 24, 2020, at 8:27 AM, Francesco Chicchiriccò  
> > wrote:
> > 
> > Hi there,
> > I would like to configure / extend 
> > org.apache.logging.log4j.core.layout.JsonLayout to produce JSON strings 
> > compliant with [1], for GCP.
> > 
> > I have found that Spring Cloud provides something like this, but based on 
> > logback [2]: if I am not mistaking, the most relevant class there is [3].
> > 
> > Do you have any suggestion about how to proceed?
> > 
> > TIA
> > Regards.
> > 
> > [1] 
> > https://cloud.google.com/logging/docs/agent/configuration#process-payload
> > [2] 
> > https://github.com/spring-cloud/spring-cloud-gcp/tree/master/spring-cloud-gcp-logging
> > [3] 
> > https://github.com/spring-cloud/spring-cloud-gcp/blob/master/spring-cloud-gcp-logging/src/main/java/org/springframework/cloud/gcp/logging/StackdriverJsonLayout.java


-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



GCP logging

2020-01-24 Thread Francesco Chicchiriccò
Hi there,
I would like to configure / extend 
org.apache.logging.log4j.core.layout.JsonLayout to produce JSON strings 
compliant with [1], for GCP.

I have found that Spring Cloud provides something like this, but based on 
logback [2]: if I am not mistaking, the most relevant class there is [3].

Do you have any suggestion about how to proceed?

TIA
Regards.

[1] https://cloud.google.com/logging/docs/agent/configuration#process-payload
[2] 
https://github.com/spring-cloud/spring-cloud-gcp/tree/master/spring-cloud-gcp-logging
[3] 
https://github.com/spring-cloud/spring-cloud-gcp/blob/master/spring-cloud-gcp-logging/src/main/java/org/springframework/cloud/gcp/logging/StackdriverJsonLayout.java


-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Re: Dynamically (programmatically) add logger in Log4j2

2013-12-16 Thread Francesco Chicchiriccò

On 16/12/2013 16:06, dxande6 wrote:

I'm trying to create an admin console for log4j2 similar to what we have done
for log4j 1.x

We list out the loggers and their current log level.  We also have links on
the right side to allow users to click on the link and let them update their
log level to any level of their choosing.  Finally, we give them a text box
to add a new logger (i.e., x.y.z), indicate their log level and click add.

Unfortunately, I have not found a way to add a new logger programmatically
in log4j2.  Does anyone have any advice on how I can do this
programmatically?  It needs to be dynamic in case the logger was not created
at the time of deployment.


Hi,
we had similar need and solved as you can see from [1] (among other 
stuff), e.g.


LoggerContext ctx = (LoggerContext) LogManager.getContext(false);

LoggerConfig logConf = ctx.getConfiguration().getLoggerConfig(THE NAME 
OF YOUR NEW LOGGER);

logConf.setLevel(...);

ctx.updateLoggers();

HTH
Regards.

[1] 
https://svn.apache.org/repos/asf/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/LoggerLoader.java


--
Francesco Chicchiriccò

Tirasa - Open Source Excellence
http://www.tirasa.net/

ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member
http://people.apache.org/~ilgrosso/


-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Any roadmap date for 2.0?

2013-12-03 Thread Francesco Chicchiriccò

Hi all,
is there already any planned release date for 2.0RC1? And what about 2.0?

Thanks.
Regards.

--
Francesco Chicchiriccò

Tirasa - Open Source Excellence
http://www.tirasa.net/

ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member
http://people.apache.org/~ilgrosso/


-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Re: Programmatically set log level in log4j2

2013-09-17 Thread Francesco Chicchiriccò

On 16/09/2013 17:51, Francesco Chicchiriccò wrote:

Hi all,
I am currently using the following code to dynamically update log 
level at runtime, after init:


LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
LoggerConfig logger = SyncopeConstants.ROOT_LOGGER.equals(name)
? 
ctx.getConfiguration().getLoggerConfig(LogManager.ROOT_LOGGER_NAME)

: ctx.getConfiguration().getLoggerConfig(name);
logger.setLevel(level);
ctx.updateLoggers();

AFAICT, I can see that the level is actually updated after 
ctx.updateLoggers() using the following code (forgive the 
'System.out.println', it's just temporary...):


for (LoggerConfig logger : 
ctx.getConfiguration().getLoggers().values()) {
final String loggerName = 
LogManager.ROOT_LOGGER_NAME.equals(logger.getName())

? SyncopeConstants.ROOT_LOGGER : logger.getName();

System.out.println(Found logger ' + loggerName + ' with 
level  + logger.getLevel());

}

Unfortunately, the level change is not effective: setting some 
logger's level to DEBUG does not change anything in the log files.

Am I doing something wrong? Thanks for your support.


Hi all,
it seems that yesterday I was making some stupid mistake: I confirm 
everything works as expected.


Regards.

--
Francesco Chicchiriccò

ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member
http://people.apache.org/~ilgrosso/


-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Programmatically set log level in log4j2

2013-09-16 Thread Francesco Chicchiriccò

Hi all,
I am currently using the following code to dynamically update log level 
at runtime, after init:


LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
LoggerConfig logger = SyncopeConstants.ROOT_LOGGER.equals(name)
? 
ctx.getConfiguration().getLoggerConfig(LogManager.ROOT_LOGGER_NAME)

: ctx.getConfiguration().getLoggerConfig(name);
logger.setLevel(level);
ctx.updateLoggers();

AFAICT, I can see that the level is actually updated after 
ctx.updateLoggers() using the following code (forgive the 
'System.out.println', it's just temporary...):


for (LoggerConfig logger : 
ctx.getConfiguration().getLoggers().values()) {
final String loggerName = 
LogManager.ROOT_LOGGER_NAME.equals(logger.getName())

? SyncopeConstants.ROOT_LOGGER : logger.getName();

System.out.println(Found logger ' + loggerName + ' with 
level  + logger.getLevel());

}

Unfortunately, the level change is not effective: setting some logger's 
level to DEBUG does not change anything in the log files.

Am I doing something wrong? Thanks for your support.

Regards.

--
Francesco Chicchiriccò

ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member
http://people.apache.org/~ilgrosso/


-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Using Spring-managed DataSource (or other Spring beans) in log4j2 configuration

2013-09-13 Thread Francesco Chicchiriccò

Hi all,
I am trying to configure a JDBCAppender in log4j 2.0-beta9-SNAPSHOT, 
with a pre-existing DataSource managed via Spring; such DataSource is 
used by the rest of Syncope.


I have tried, without success. to provide a custom ConnectionSource or a 
ConnectionFactory: the point is that, when log4j2 initializes, the 
Spring context is yet to be built, hence no beans (including the 
DataSource referenced above) are available.


I have read from [1] that log4j2 features an automatic configuration: 
is there any way to disable it and invoke it manually later?


Thanks for your support.
Regards.

[1] 
http://logging.apache.org/log4j/2.x/manual/configuration.html#AutomaticConfiguration


--
Francesco Chicchiriccò

ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member
http://people.apache.org/~ilgrosso/



Re: Using the SLF4J Bridge

2013-09-04 Thread Francesco Chicchiriccò

On 03/09/2013 22:19, Gary Gregory wrote:

The tests works for me:

[...]
My set up:

Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19
08:51:28-0500)
Maven home: C:\Java\apache-maven-3.0.5\bin\..
Java version: 1.7.0_25, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_25\jre
Default locale: en_US, platform encoding: Cp1252
OS name: windows 7, version: 6.1, arch: amd64, family: windows


Hi,
I confirm it works on Linux as well, either with Maven 3.1.0 and Maven 
3.0.5: once seen your configuration, I remembered that I was using a 
mangled Maven 3.1.0 installation, as per blog post [5] (I actually loved 
the idea of colorized output).


At the moment I've switched back to vanilla Maven 3.1.0 and everything 
is working fine again.


Thanks for your support.

Regards.


On Mon, Sep 2, 2013 at 6:47 AM, Francesco Chicchiriccò
ilgro...@apache.orgwrote:


On 02/09/2013 10:39, Francesco Chicchiriccň wrote:


Hi all,
at Syncope we are currently migrating from Logback to Log4j 2.0, as per
SYNCOPE-405 [1].

Our codebase is almost completely based on SLF4J API, so we are
evaluating the SLF4J bridge [2] (e.g. log4j-slf4j-impl): this works almost
fine, except for some classes (like as [3]) where we need to
programmatically set some logger levels.

I was able to do this with lo4j only by including log4j-core;
unfortunately it seems that including both log4j-slf4j-impl and log4j-core
generates some kind of block.

Am I doing something wrong?

We are using the last stable release (2.0-beta8).


In order to ease hunting, I have forked the Apache Syncope repository and
created a LOG4J2 branch on my own fork [4] that is using both
log4j-slf4j-impl and log4j-core: to reproduce, just clone, switch to the
LOG4J2 branch and:

$ mvn -PskipTests
$ cd core
$ mvn clean test

At this point the first unit test 
(org.apache.syncope.core.**connid.PasswordGeneratorTest)
will hang.


Regards.

  [1] 
https://issues.apache.org/**jira/browse/SYNCOPE-405https://issues.apache.org/jira/browse/SYNCOPE-405

[2] 
http://logging.apache.org/**log4j/2.x/log4j-slf4j-impl/**index.htmlhttp://logging.apache.org/log4j/2.x/log4j-slf4j-impl/index.html
[3] https://svn.apache.org/repos/**asf/syncope/trunk/core/src/**
main/java/org/apache/syncope/**core/init/LoggerLoader.javahttps://svn.apache.org/repos/asf/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/LoggerLoader.java


[4] 
https://github.com/ilgrosso/**syncope/tree/LOG4J2https://github.com/ilgrosso/syncope/tree/LOG4J2

[5] http://aheritier.net/united-colors-of-maven/

--
Francesco Chicchiriccò

ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member
http://people.apache.org/~ilgrosso/


-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Re: Using the SLF4J Bridge

2013-09-04 Thread Francesco Chicchiriccò

On 04/09/2013 09:10, Francesco Chicchiriccò wrote:

On 03/09/2013 22:19, Gary Gregory wrote:

The tests works for me:

[...]
My set up:

Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 
2013-02-19

08:51:28-0500)
Maven home: C:\Java\apache-maven-3.0.5\bin\..
Java version: 1.7.0_25, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_25\jre
Default locale: en_US, platform encoding: Cp1252
OS name: windows 7, version: 6.1, arch: amd64, family: windows


Hi,
I confirm it works on Linux as well, either with Maven 3.1.0 and Maven 
3.0.5: once seen your configuration, I remembered that I was using a 
mangled Maven 3.1.0 installation, as per blog post [5] (I actually 
loved the idea of colorized output).


At the moment I've switched back to vanilla Maven 3.1.0 and everything 
is working fine again.


Update: on Linux, with OpenJDK 6 / Oracle JDK6 everything works fine.
With Oracle JDK 7 everything is fine as well, but with OpenJDK 7 test 
execution hangs:


java version 1.7.0_25
OpenJDK Runtime Environment (IcedTea 2.3.12) (7u25-2.3.12-4)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

Using vanilla or colorized Maven 3.1.0 does not make any difference.

Any clue?

Regards.


On Mon, Sep 2, 2013 at 6:47 AM, Francesco Chicchiriccò
ilgro...@apache.orgwrote:


On 02/09/2013 10:39, Francesco Chicchiriccň wrote:


Hi all,
at Syncope we are currently migrating from Logback to Log4j 2.0, as 
per

SYNCOPE-405 [1].

Our codebase is almost completely based on SLF4J API, so we are
evaluating the SLF4J bridge [2] (e.g. log4j-slf4j-impl): this works 
almost

fine, except for some classes (like as [3]) where we need to
programmatically set some logger levels.

I was able to do this with lo4j only by including log4j-core;
unfortunately it seems that including both log4j-slf4j-impl and 
log4j-core

generates some kind of block.

Am I doing something wrong?

We are using the last stable release (2.0-beta8).

In order to ease hunting, I have forked the Apache Syncope 
repository and

created a LOG4J2 branch on my own fork [4] that is using both
log4j-slf4j-impl and log4j-core: to reproduce, just clone, switch to 
the

LOG4J2 branch and:

$ mvn -PskipTests
$ cd core
$ mvn clean test

At this point the first unit test 
(org.apache.syncope.core.**connid.PasswordGeneratorTest)

will hang.


Regards.

  [1] 
https://issues.apache.org/**jira/browse/SYNCOPE-405https://issues.apache.org/jira/browse/SYNCOPE-405
[2] 
http://logging.apache.org/**log4j/2.x/log4j-slf4j-impl/**index.htmlhttp://logging.apache.org/log4j/2.x/log4j-slf4j-impl/index.html

[3] https://svn.apache.org/repos/**asf/syncope/trunk/core/src/**
main/java/org/apache/syncope/**core/init/LoggerLoader.javahttps://svn.apache.org/repos/asf/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/LoggerLoader.java 



[4] 
https://github.com/ilgrosso/**syncope/tree/LOG4J2https://github.com/ilgrosso/syncope/tree/LOG4J2

[5] http://aheritier.net/united-colors-of-maven/


--
Francesco Chicchiriccò

ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member
http://people.apache.org/~ilgrosso/


-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Re: Using the SLF4J Bridge

2013-09-04 Thread Francesco Chicchiriccò

On 04/09/2013 14:14, Gary Gregory wrote:

[...]

Update: on Linux, with OpenJDK 6 / Oracle JDK6 everything works fine.
With Oracle JDK 7 everything is fine as well, but with OpenJDK 7 test
execution hangs:

java version 1.7.0_25
OpenJDK Runtime Environment (IcedTea 2.3.12) (7u25-2.3.12-4)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

Using vanilla or colorized Maven 3.1.0 does not make any difference.

Any clue?

On Windows/Oracle, you can hit Ctrl-Break on the command line and get a JVM
dump of what all threads are doing. I would try that when the JVM appears
hung.


On Linux it's CTRL+ATL+\ - here you go: http://apaste.info/fPVg

Thanks for your support.
Regards.

--
Francesco Chicchiriccò

ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member
http://people.apache.org/~ilgrosso/



Re: Using the SLF4J Bridge

2013-09-04 Thread Francesco Chicchiriccò

On 04/09/2013 14:37, Ralph Goers wrote:

Also, I think Nick made changes to how we are calling getCallerClass in trunk, 
so if you want to use that version of OpenJDK you might need to use the latest 
code.


I have downloaded JDK7u40 Early Access from 
https://jdk7.java.net/download.html and set log4j artifacts version to 
2.0-beta9-SNAPSHOT: no hung occurred.


Afterwards, I've switched back to OpenJDK7u25 (still with log4j 
2.0-beta9-SNAPSHOT) and everything worked as well; finally successfully 
tested even with Oracle JDK 7.


Guess I've solved our problem on Syncope for the moment: we'll stay on 
2.0-beta9-SNAPSHOT which is expected to be released way before our next 
major release (featuring log4j).


Thanks for your support.
Regards.


On Sep 4, 2013, at 6:35 AM, Ralph Goers rgo...@apache.org wrote:


I see a thread in getCallerClass.  I don't recall what the status of 7u25 is 
(Nick would probably know), but OpenJDK has been going back and forth on that 
method.  I think there might be a newer OpenJDK release (40?) that fixes the 
problem.

Sent from my iPad

On Sep 4, 2013, at 6:19 AM, Francesco Chicchiriccò ilgro...@apache.org wrote:


On 04/09/2013 14:14, Gary Gregory wrote:

[...]

Update: on Linux, with OpenJDK 6 / Oracle JDK6 everything works fine.
With Oracle JDK 7 everything is fine as well, but with OpenJDK 7 test
execution hangs:

java version 1.7.0_25
OpenJDK Runtime Environment (IcedTea 2.3.12) (7u25-2.3.12-4)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

Using vanilla or colorized Maven 3.1.0 does not make any difference.

Any clue?

On Windows/Oracle, you can hit Ctrl-Break on the command line and get a JVM
dump of what all threads are doing. I would try that when the JVM appears
hung.

On Linux it's CTRL+ATL+\ - here you go: http://apaste.info/fPVg

Thanks for your support.
Regards.


--
Francesco Chicchiriccò

ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member
http://people.apache.org/~ilgrosso/


-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Using the SLF4J Bridge

2013-09-02 Thread Francesco Chicchiriccò

Hi all,
at Syncope we are currently migrating from Logback to Log4j 2.0, as per 
SYNCOPE-405 [1].


Our codebase is almost completely based on SLF4J API, so we are 
evaluating the SLF4J bridge [2] (e.g. log4j-slf4j-impl): this works 
almost fine, except for some classes (like as [3]) where we need to 
programmatically set some logger levels.


I was able to do this with lo4j only by including log4j-core; 
unfortunately it seems that including both log4j-slf4j-impl and 
log4j-core generates some kind of block.


Am I doing something wrong?

We are using the last stable release (2.0-beta8).

Regards.

[1] https://issues.apache.org/jira/browse/SYNCOPE-405
[2] http://logging.apache.org/log4j/2.x/log4j-slf4j-impl/index.html
[3] 
https://svn.apache.org/repos/asf/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/LoggerLoader.java


--
Francesco Chicchiriccò

ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member
http://people.apache.org/~ilgrosso/


-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Re: Using the SLF4J Bridge

2013-09-02 Thread Francesco Chicchiriccò

On 02/09/2013 10:39, Francesco Chicchiriccò wrote:

Hi all,
at Syncope we are currently migrating from Logback to Log4j 2.0, as 
per SYNCOPE-405 [1].


Our codebase is almost completely based on SLF4J API, so we are 
evaluating the SLF4J bridge [2] (e.g. log4j-slf4j-impl): this works 
almost fine, except for some classes (like as [3]) where we need to 
programmatically set some logger levels.


I was able to do this with lo4j only by including log4j-core; 
unfortunately it seems that including both log4j-slf4j-impl and 
log4j-core generates some kind of block.


Am I doing something wrong?

We are using the last stable release (2.0-beta8).


In order to ease hunting, I have forked the Apache Syncope repository 
and created a LOG4J2 branch on my own fork [4] that is using both 
log4j-slf4j-impl and log4j-core: to reproduce, just clone, switch to the 
LOG4J2 branch and:


$ mvn -PskipTests
$ cd core
$ mvn clean test

At this point the first unit test 
(org.apache.syncope.core.connid.PasswordGeneratorTest) will hang.


Regards.


[1] https://issues.apache.org/jira/browse/SYNCOPE-405
[2] http://logging.apache.org/log4j/2.x/log4j-slf4j-impl/index.html
[3] 
https://svn.apache.org/repos/asf/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/LoggerLoader.java

[4] https://github.com/ilgrosso/syncope/tree/LOG4J2

--
Francesco Chicchiriccò

ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member
http://people.apache.org/~ilgrosso/


-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org