[jira] [Commented] (LOG4J2-3396) ERROR Recursive call to appender mongodb with spring boot root logger

2022-02-22 Thread Ralph Goers (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-3396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17496251#comment-17496251
 ] 

Ralph Goers commented on LOG4J2-3396:
-

Yes, Gary is mistaken. MongoDB may log to SLF4J but then that is bridged to 
Log4j which then tries to log it to MongoDB and it all starts over again. 

> ERROR Recursive call to appender mongodb with spring boot root logger
> -
>
> Key: LOG4J2-3396
> URL: https://issues.apache.org/jira/browse/LOG4J2-3396
> Project: Log4j 2
>  Issue Type: Question
>  Components: MongoDB
>Affects Versions: 2.17.1
>Reporter: Omer U
>Priority: Major
>
> If mongodb4 logger is used as root logger in basic spring boot rest 
> application, it causes some sort of recursion error. And stalls startup. 
>  below causes recursive call error
> {code:xml}
>  
>   
>   
>  
> {code}
> while following does not produce error
> {code:xml}
>   
> 
>   
> 
> 
>   
> 
> 
>   
> {code}
>  
> {noformat}
> 2022-02-07 23:35:43,487 cluster-ClusterId{value='620182632ff6a504abdb6699', 
> description='null'}-localhost:27017 ERROR Recursive call to appender mongodb
> 23:36:13.481 [st:27017] INFO  o.m.d.cluster - Cluster description not yet 
> available. Waiting for 3 ms before timing out
> 2022-02-07 23:36:13,480 
> cluster-rtt-ClusterId{value='620182632ff6a504abdb6697', 
> description='null'}-localhost:27017 ERROR Unable to write to database 
> [noSqlManager{ description=mongodb, bufferSize=0, provider=MongoDb4Provider 
> [connectionString=mongodb://localhost:27017/tombolog.mongo4test, 
> collectionSize=1073741824, isCapped=true, 
> mongoClient=com.mongodb.client.internal.MongoClientImpl@2f67a4d3, 
> mongoDatabase=com.mongodb.client.internal.MongoDatabaseImpl@5e3f861] }] for 
> appender [mongodb]. 
> org.apache.logging.log4j.core.appender.AppenderLoggingException: Failed to 
> write log event to MongoDB due to error: Timed out after 3 ms while 
> waiting to connect. Client view of cluster state is {type=UNKNOWN, 
> servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING}]
> {noformat}
> full log4j2.xml file
> {code:xml}
> 
> 
>   
> 
>   
> 
> 
>connection="${env:MONGO_LOG_URI:-mongodb://localhost:27017/log.mongo4test}" />
> 
>   
>   
> 
>   
>   
> 
> 
> 
>   
> 
> {code}
> build.gradle
> {code:groovy}
> plugins {
>   id 'org.springframework.boot' version '2.6.3'
>   id 'io.spring.dependency-management' version '1.0.11.RELEASE'
>   id 'java'
> }
> group = 'com.example'
> version = '0.0.1-SNAPSHOT'
> sourceCompatibility = '11'
> ext ['log4j2.version'] = '2.17.2-SNAPSHOT'
> repositories {
> mavenCentral()
> maven {
> url "http://repository.apache.org/content/repositories/snapshots/";
> }
> }
> dependencies {
>   implementation group: 'org.apache.logging.log4j', name: 
> 'log4j-mongodb4', version: '2.17.2-SNAPSHOT'
>   implementation 'org.springframework.boot:spring-boot-starter-web'
>   implementation 'org.springframework.boot:spring-boot-starter-log4j2'
>   testImplementation 'org.springframework.boot:spring-boot-starter-test'
> }
> configurations {
>   all {
>   exclude group: 'org.springframework.boot', module: 
> 'spring-boot-starter-logging'
>   exclude group: 'org.springframework.boot', module: 
> 'logback-classic'
>   }
> }
> tasks.named('test') {
>   useJUnitPlatform()
> }
> {code}
> is this normal behavior? I have tried to reproduce this without spring boot  
> without any success. 
> Any ideas?



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (LOG4J2-3396) ERROR Recursive call to appender mongodb with spring boot root logger

2022-02-22 Thread Omer U (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-3396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17496189#comment-17496189
 ] 

Omer U commented on LOG4J2-3396:


[~ggregory], If I understood correctly for loop to happen, both 
log4j-slf4j-impl and log4j-to-slf4j should be in the classpath.

However only log4j-slf4j-impl seems to be in classpath.

 
{code:bash}
$ gradle dependencies  |grep slf4 | awk -F' o' '{print "o"$2}' | sort -u | awk 
-F[:\ ] '{print $1":"$2}' | sort -u
org.apache.logging.log4j:log4j-slf4j-impl
org.slf4j:jul-to-slf4j
org.slf4j:slf4j-api
{code}
{code:bash}
$ gradle dependencies  |grep log4j | awk -F' o' '{print "o"$2}' | sort -u | awk 
-F[:\ ] '{print $1":"$2}' | sort -u
org.apache.logging.log4j:log4j-api
org.apache.logging.log4j:log4j-core
org.apache.logging.log4j:log4j-jul
org.apache.logging.log4j:log4j-mongodb4
org.apache.logging.log4j:log4j-slf4j-impl
org.springframework.boot:spring-boot-starter-log4j2
{code}

> ERROR Recursive call to appender mongodb with spring boot root logger
> -
>
> Key: LOG4J2-3396
> URL: https://issues.apache.org/jira/browse/LOG4J2-3396
> Project: Log4j 2
>  Issue Type: Question
>  Components: MongoDB
>Affects Versions: 2.17.1
>Reporter: Omer U
>Priority: Major
>
> If mongodb4 logger is used as root logger in basic spring boot rest 
> application, it causes some sort of recursion error. And stalls startup. 
>  below causes recursive call error
> {code:xml}
>  
>   
>   
>  
> {code}
> while following does not produce error
> {code:xml}
>   
> 
>   
> 
> 
>   
> 
> 
>   
> {code}
>  
> {noformat}
> 2022-02-07 23:35:43,487 cluster-ClusterId{value='620182632ff6a504abdb6699', 
> description='null'}-localhost:27017 ERROR Recursive call to appender mongodb
> 23:36:13.481 [st:27017] INFO  o.m.d.cluster - Cluster description not yet 
> available. Waiting for 3 ms before timing out
> 2022-02-07 23:36:13,480 
> cluster-rtt-ClusterId{value='620182632ff6a504abdb6697', 
> description='null'}-localhost:27017 ERROR Unable to write to database 
> [noSqlManager{ description=mongodb, bufferSize=0, provider=MongoDb4Provider 
> [connectionString=mongodb://localhost:27017/tombolog.mongo4test, 
> collectionSize=1073741824, isCapped=true, 
> mongoClient=com.mongodb.client.internal.MongoClientImpl@2f67a4d3, 
> mongoDatabase=com.mongodb.client.internal.MongoDatabaseImpl@5e3f861] }] for 
> appender [mongodb]. 
> org.apache.logging.log4j.core.appender.AppenderLoggingException: Failed to 
> write log event to MongoDB due to error: Timed out after 3 ms while 
> waiting to connect. Client view of cluster state is {type=UNKNOWN, 
> servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING}]
> {noformat}
> full log4j2.xml file
> {code:xml}
> 
> 
>   
> 
>   
> 
> 
>connection="${env:MONGO_LOG_URI:-mongodb://localhost:27017/log.mongo4test}" />
> 
>   
>   
> 
>   
>   
> 
> 
> 
>   
> 
> {code}
> build.gradle
> {code:groovy}
> plugins {
>   id 'org.springframework.boot' version '2.6.3'
>   id 'io.spring.dependency-management' version '1.0.11.RELEASE'
>   id 'java'
> }
> group = 'com.example'
> version = '0.0.1-SNAPSHOT'
> sourceCompatibility = '11'
> ext ['log4j2.version'] = '2.17.2-SNAPSHOT'
> repositories {
> mavenCentral()
> maven {
> url "http://repository.apache.org/content/repositories/snapshots/";
> }
> }
> dependencies {
>   implementation group: 'org.apache.logging.log4j', name: 
> 'log4j-mongodb4', version: '2.17.2-SNAPSHOT'
>   implementation 'org.springframework.boot:spring-boot-starter-web'
>   implementation 'org.springframework.boot:spring-boot-starter-log4j2'
>   testImplementation 'org.springframework.boot:spring-boot-starter-test'
> }
> configurations {
>   all {
>   exclude group: 'org.springframework.boot', module: 
> 'spring-boot-starter-logging'
>   exclude group: 'org.springframework.boot', module: 
> 'logback-classic'
>   }
> }
> tasks.named('test') {
>   useJUnitPlatform()
> }
> {code}
> is this normal behavior? I have tried to reproduce this without spring boot  
> without any success. 
> Any ideas?



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (LOG4J2-3396) ERROR Recursive call to appender mongodb with spring boot root logger

2022-02-22 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-3396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17496096#comment-17496096
 ] 

Gary D. Gregory commented on LOG4J2-3396:
-

I am guessing there is a loop between slf4j and Log4j as the MongoDB client 
depends on slf4j: 
[https://search.maven.org/artifact/org.mongodb/mongodb-driver-sync/4.5.0/jar]

This can be configured to work as documented here: 
[https://logging.apache.org/log4j/2.x/log4j-slf4j-impl/index.html]

> ERROR Recursive call to appender mongodb with spring boot root logger
> -
>
> Key: LOG4J2-3396
> URL: https://issues.apache.org/jira/browse/LOG4J2-3396
> Project: Log4j 2
>  Issue Type: Question
>  Components: MongoDB
>Affects Versions: 2.17.1
>Reporter: Omer U
>Priority: Major
>
> If mongodb4 logger is used as root logger in basic spring boot rest 
> application, it causes some sort of recursion error. And stalls startup. 
>  below causes recursive call error
> {code:xml}
>  
>   
>   
>  
> {code}
> while following does not produce error
> {code:xml}
>   
> 
>   
> 
> 
>   
> 
> 
>   
> {code}
>  
> {noformat}
> 2022-02-07 23:35:43,487 cluster-ClusterId{value='620182632ff6a504abdb6699', 
> description='null'}-localhost:27017 ERROR Recursive call to appender mongodb
> 23:36:13.481 [st:27017] INFO  o.m.d.cluster - Cluster description not yet 
> available. Waiting for 3 ms before timing out
> 2022-02-07 23:36:13,480 
> cluster-rtt-ClusterId{value='620182632ff6a504abdb6697', 
> description='null'}-localhost:27017 ERROR Unable to write to database 
> [noSqlManager{ description=mongodb, bufferSize=0, provider=MongoDb4Provider 
> [connectionString=mongodb://localhost:27017/tombolog.mongo4test, 
> collectionSize=1073741824, isCapped=true, 
> mongoClient=com.mongodb.client.internal.MongoClientImpl@2f67a4d3, 
> mongoDatabase=com.mongodb.client.internal.MongoDatabaseImpl@5e3f861] }] for 
> appender [mongodb]. 
> org.apache.logging.log4j.core.appender.AppenderLoggingException: Failed to 
> write log event to MongoDB due to error: Timed out after 3 ms while 
> waiting to connect. Client view of cluster state is {type=UNKNOWN, 
> servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING}]
> {noformat}
> full log4j2.xml file
> {code:xml}
> 
> 
>   
> 
>   
> 
> 
>connection="${env:MONGO_LOG_URI:-mongodb://localhost:27017/log.mongo4test}" />
> 
>   
>   
> 
>   
>   
> 
> 
> 
>   
> 
> {code}
> build.gradle
> {code:groovy}
> plugins {
>   id 'org.springframework.boot' version '2.6.3'
>   id 'io.spring.dependency-management' version '1.0.11.RELEASE'
>   id 'java'
> }
> group = 'com.example'
> version = '0.0.1-SNAPSHOT'
> sourceCompatibility = '11'
> ext ['log4j2.version'] = '2.17.2-SNAPSHOT'
> repositories {
> mavenCentral()
> maven {
> url "http://repository.apache.org/content/repositories/snapshots/";
> }
> }
> dependencies {
>   implementation group: 'org.apache.logging.log4j', name: 
> 'log4j-mongodb4', version: '2.17.2-SNAPSHOT'
>   implementation 'org.springframework.boot:spring-boot-starter-web'
>   implementation 'org.springframework.boot:spring-boot-starter-log4j2'
>   testImplementation 'org.springframework.boot:spring-boot-starter-test'
> }
> configurations {
>   all {
>   exclude group: 'org.springframework.boot', module: 
> 'spring-boot-starter-logging'
>   exclude group: 'org.springframework.boot', module: 
> 'logback-classic'
>   }
> }
> tasks.named('test') {
>   useJUnitPlatform()
> }
> {code}
> is this normal behavior? I have tried to reproduce this without spring boot  
> without any success. 
> Any ideas?



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (LOG4J2-3396) ERROR Recursive call to appender mongodb with spring boot root logger

2022-02-22 Thread Omer U (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-3396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17496031#comment-17496031
 ] 

Omer U commented on LOG4J2-3396:


[~ppkarwasz] thank you. This seem to work. No stall, all logs except driver. 
Only missing thing is logs from the driver logged to db.

{code:xml}
  

  
  


  

  
{code}


> ERROR Recursive call to appender mongodb with spring boot root logger
> -
>
> Key: LOG4J2-3396
> URL: https://issues.apache.org/jira/browse/LOG4J2-3396
> Project: Log4j 2
>  Issue Type: Question
>  Components: MongoDB
>Affects Versions: 2.17.1
>Reporter: Omer U
>Priority: Major
>
> If mongodb4 logger is used as root logger in basic spring boot rest 
> application, it causes some sort of recursion error. And stalls startup. 
>  below causes recursive call error
> {code:xml}
>  
>   
>   
>  
> {code}
> while following does not produce error
> {code:xml}
>   
> 
>   
> 
> 
>   
> 
> 
>   
> {code}
>  
> {noformat}
> 2022-02-07 23:35:43,487 cluster-ClusterId{value='620182632ff6a504abdb6699', 
> description='null'}-localhost:27017 ERROR Recursive call to appender mongodb
> 23:36:13.481 [st:27017] INFO  o.m.d.cluster - Cluster description not yet 
> available. Waiting for 3 ms before timing out
> 2022-02-07 23:36:13,480 
> cluster-rtt-ClusterId{value='620182632ff6a504abdb6697', 
> description='null'}-localhost:27017 ERROR Unable to write to database 
> [noSqlManager{ description=mongodb, bufferSize=0, provider=MongoDb4Provider 
> [connectionString=mongodb://localhost:27017/tombolog.mongo4test, 
> collectionSize=1073741824, isCapped=true, 
> mongoClient=com.mongodb.client.internal.MongoClientImpl@2f67a4d3, 
> mongoDatabase=com.mongodb.client.internal.MongoDatabaseImpl@5e3f861] }] for 
> appender [mongodb]. 
> org.apache.logging.log4j.core.appender.AppenderLoggingException: Failed to 
> write log event to MongoDB due to error: Timed out after 3 ms while 
> waiting to connect. Client view of cluster state is {type=UNKNOWN, 
> servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING}]
> {noformat}
> full log4j2.xml file
> {code:xml}
> 
> 
>   
> 
>   
> 
> 
>connection="${env:MONGO_LOG_URI:-mongodb://localhost:27017/log.mongo4test}" />
> 
>   
>   
> 
>   
>   
> 
> 
> 
>   
> 
> {code}
> build.gradle
> {code:groovy}
> plugins {
>   id 'org.springframework.boot' version '2.6.3'
>   id 'io.spring.dependency-management' version '1.0.11.RELEASE'
>   id 'java'
> }
> group = 'com.example'
> version = '0.0.1-SNAPSHOT'
> sourceCompatibility = '11'
> ext ['log4j2.version'] = '2.17.2-SNAPSHOT'
> repositories {
> mavenCentral()
> maven {
> url "http://repository.apache.org/content/repositories/snapshots/";
> }
> }
> dependencies {
>   implementation group: 'org.apache.logging.log4j', name: 
> 'log4j-mongodb4', version: '2.17.2-SNAPSHOT'
>   implementation 'org.springframework.boot:spring-boot-starter-web'
>   implementation 'org.springframework.boot:spring-boot-starter-log4j2'
>   testImplementation 'org.springframework.boot:spring-boot-starter-test'
> }
> configurations {
>   all {
>   exclude group: 'org.springframework.boot', module: 
> 'spring-boot-starter-logging'
>   exclude group: 'org.springframework.boot', module: 
> 'logback-classic'
>   }
> }
> tasks.named('test') {
>   useJUnitPlatform()
> }
> {code}
> is this normal behavior? I have tried to reproduce this without spring boot  
> without any success. 
> Any ideas?



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (LOG4J2-3396) ERROR Recursive call to appender mongodb with spring boot root logger

2022-02-22 Thread Piotr P. Karwasz (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-3396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17496024#comment-17496024
 ] 

Piotr P. Karwasz commented on LOG4J2-3396:
--

Have you tried:
{code:xml}
  

  
  


  

  
{code}

> ERROR Recursive call to appender mongodb with spring boot root logger
> -
>
> Key: LOG4J2-3396
> URL: https://issues.apache.org/jira/browse/LOG4J2-3396
> Project: Log4j 2
>  Issue Type: Question
>  Components: MongoDB
>Affects Versions: 2.17.1
>Reporter: Omer U
>Priority: Major
>
> If mongodb4 logger is used as root logger in basic spring boot rest 
> application, it causes some sort of recursion error. And stalls startup. 
>  below causes recursive call error
> {code:xml}
>  
>   
>   
>  
> {code}
> while following does not produce error
> {code:xml}
>   
> 
>   
> 
> 
>   
> 
> 
>   
> {code}
>  
> {noformat}
> 2022-02-07 23:35:43,487 cluster-ClusterId{value='620182632ff6a504abdb6699', 
> description='null'}-localhost:27017 ERROR Recursive call to appender mongodb
> 23:36:13.481 [st:27017] INFO  o.m.d.cluster - Cluster description not yet 
> available. Waiting for 3 ms before timing out
> 2022-02-07 23:36:13,480 
> cluster-rtt-ClusterId{value='620182632ff6a504abdb6697', 
> description='null'}-localhost:27017 ERROR Unable to write to database 
> [noSqlManager{ description=mongodb, bufferSize=0, provider=MongoDb4Provider 
> [connectionString=mongodb://localhost:27017/tombolog.mongo4test, 
> collectionSize=1073741824, isCapped=true, 
> mongoClient=com.mongodb.client.internal.MongoClientImpl@2f67a4d3, 
> mongoDatabase=com.mongodb.client.internal.MongoDatabaseImpl@5e3f861] }] for 
> appender [mongodb]. 
> org.apache.logging.log4j.core.appender.AppenderLoggingException: Failed to 
> write log event to MongoDB due to error: Timed out after 3 ms while 
> waiting to connect. Client view of cluster state is {type=UNKNOWN, 
> servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING}]
> {noformat}
> full log4j2.xml file
> {code:xml}
> 
> 
>   
> 
>   
> 
> 
>connection="${env:MONGO_LOG_URI:-mongodb://localhost:27017/log.mongo4test}" />
> 
>   
>   
> 
>   
>   
> 
> 
> 
>   
> 
> {code}
> build.gradle
> {code:groovy}
> plugins {
>   id 'org.springframework.boot' version '2.6.3'
>   id 'io.spring.dependency-management' version '1.0.11.RELEASE'
>   id 'java'
> }
> group = 'com.example'
> version = '0.0.1-SNAPSHOT'
> sourceCompatibility = '11'
> ext ['log4j2.version'] = '2.17.2-SNAPSHOT'
> repositories {
> mavenCentral()
> maven {
> url "http://repository.apache.org/content/repositories/snapshots/";
> }
> }
> dependencies {
>   implementation group: 'org.apache.logging.log4j', name: 
> 'log4j-mongodb4', version: '2.17.2-SNAPSHOT'
>   implementation 'org.springframework.boot:spring-boot-starter-web'
>   implementation 'org.springframework.boot:spring-boot-starter-log4j2'
>   testImplementation 'org.springframework.boot:spring-boot-starter-test'
> }
> configurations {
>   all {
>   exclude group: 'org.springframework.boot', module: 
> 'spring-boot-starter-logging'
>   exclude group: 'org.springframework.boot', module: 
> 'logback-classic'
>   }
> }
> tasks.named('test') {
>   useJUnitPlatform()
> }
> {code}
> is this normal behavior? I have tried to reproduce this without spring boot  
> without any success. 
> Any ideas?



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (LOG4J2-3396) ERROR Recursive call to appender mongodb with spring boot root logger

2022-02-22 Thread Omer U (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-3396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17495999#comment-17495999
 ] 

Omer U commented on LOG4J2-3396:


Will we be able to run mongodb appender for root logger? May be mongodb 
appender could check and postpone/buffer logs coming from itself, until 
connection is established?

Current behavior is interesting. Application stalls for 30+ seconds, then 
application starts, and logging works.


> ERROR Recursive call to appender mongodb with spring boot root logger
> -
>
> Key: LOG4J2-3396
> URL: https://issues.apache.org/jira/browse/LOG4J2-3396
> Project: Log4j 2
>  Issue Type: Question
>  Components: MongoDB
>Affects Versions: 2.17.1
>Reporter: Omer U
>Priority: Major
>
> If mongodb4 logger is used as root logger in basic spring boot rest 
> application, it causes some sort of recursion error. And stalls startup. 
>  below causes recursive call error
> {code:xml}
>  
>   
>   
>  
> {code}
> while following does not produce error
> {code:xml}
>   
> 
>   
> 
> 
>   
> 
> 
>   
> {code}
>  
> {noformat}
> 2022-02-07 23:35:43,487 cluster-ClusterId{value='620182632ff6a504abdb6699', 
> description='null'}-localhost:27017 ERROR Recursive call to appender mongodb
> 23:36:13.481 [st:27017] INFO  o.m.d.cluster - Cluster description not yet 
> available. Waiting for 3 ms before timing out
> 2022-02-07 23:36:13,480 
> cluster-rtt-ClusterId{value='620182632ff6a504abdb6697', 
> description='null'}-localhost:27017 ERROR Unable to write to database 
> [noSqlManager{ description=mongodb, bufferSize=0, provider=MongoDb4Provider 
> [connectionString=mongodb://localhost:27017/tombolog.mongo4test, 
> collectionSize=1073741824, isCapped=true, 
> mongoClient=com.mongodb.client.internal.MongoClientImpl@2f67a4d3, 
> mongoDatabase=com.mongodb.client.internal.MongoDatabaseImpl@5e3f861] }] for 
> appender [mongodb]. 
> org.apache.logging.log4j.core.appender.AppenderLoggingException: Failed to 
> write log event to MongoDB due to error: Timed out after 3 ms while 
> waiting to connect. Client view of cluster state is {type=UNKNOWN, 
> servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING}]
> {noformat}
> full log4j2.xml file
> {code:xml}
> 
> 
>   
> 
>   
> 
> 
>connection="${env:MONGO_LOG_URI:-mongodb://localhost:27017/log.mongo4test}" />
> 
>   
>   
> 
>   
>   
> 
> 
> 
>   
> 
> {code}
> build.gradle
> {code:groovy}
> plugins {
>   id 'org.springframework.boot' version '2.6.3'
>   id 'io.spring.dependency-management' version '1.0.11.RELEASE'
>   id 'java'
> }
> group = 'com.example'
> version = '0.0.1-SNAPSHOT'
> sourceCompatibility = '11'
> ext ['log4j2.version'] = '2.17.2-SNAPSHOT'
> repositories {
> mavenCentral()
> maven {
> url "http://repository.apache.org/content/repositories/snapshots/";
> }
> }
> dependencies {
>   implementation group: 'org.apache.logging.log4j', name: 
> 'log4j-mongodb4', version: '2.17.2-SNAPSHOT'
>   implementation 'org.springframework.boot:spring-boot-starter-web'
>   implementation 'org.springframework.boot:spring-boot-starter-log4j2'
>   testImplementation 'org.springframework.boot:spring-boot-starter-test'
> }
> configurations {
>   all {
>   exclude group: 'org.springframework.boot', module: 
> 'spring-boot-starter-logging'
>   exclude group: 'org.springframework.boot', module: 
> 'logback-classic'
>   }
> }
> tasks.named('test') {
>   useJUnitPlatform()
> }
> {code}
> is this normal behavior? I have tried to reproduce this without spring boot  
> without any success. 
> Any ideas?



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (LOG4J2-3396) ERROR Recursive call to appender mongodb with spring boot root logger

2022-02-19 Thread Ralph Goers (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-3396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17494916#comment-17494916
 ] 

Ralph Goers commented on LOG4J2-3396:
-

I will have to look at the example but I am 100% certain the issue is that the 
MongoDB client is using Log4j for logging. Those logs are then routed to the 
MongoDB appender and you have an endless loop. 

The fix is to provide a logger that matches what MongoDB uses and route those 
message to a different destination.

> ERROR Recursive call to appender mongodb with spring boot root logger
> -
>
> Key: LOG4J2-3396
> URL: https://issues.apache.org/jira/browse/LOG4J2-3396
> Project: Log4j 2
>  Issue Type: Question
>  Components: MongoDB
>Affects Versions: 2.17.1
>Reporter: Omer U
>Priority: Major
>
> If mongodb4 logger is used as root logger in basic spring boot rest 
> application, it causes some sort of recursion error. And stalls startup. 
>  below causes recursive call error
> {code:xml}
>  
>   
>   
>  
> {code}
> while following does not produce error
> {code:xml}
>   
> 
>   
> 
> 
>   
> 
> 
>   
> {code}
>  
> {noformat}
> 2022-02-07 23:35:43,487 cluster-ClusterId{value='620182632ff6a504abdb6699', 
> description='null'}-localhost:27017 ERROR Recursive call to appender mongodb
> 23:36:13.481 [st:27017] INFO  o.m.d.cluster - Cluster description not yet 
> available. Waiting for 3 ms before timing out
> 2022-02-07 23:36:13,480 
> cluster-rtt-ClusterId{value='620182632ff6a504abdb6697', 
> description='null'}-localhost:27017 ERROR Unable to write to database 
> [noSqlManager{ description=mongodb, bufferSize=0, provider=MongoDb4Provider 
> [connectionString=mongodb://localhost:27017/tombolog.mongo4test, 
> collectionSize=1073741824, isCapped=true, 
> mongoClient=com.mongodb.client.internal.MongoClientImpl@2f67a4d3, 
> mongoDatabase=com.mongodb.client.internal.MongoDatabaseImpl@5e3f861] }] for 
> appender [mongodb]. 
> org.apache.logging.log4j.core.appender.AppenderLoggingException: Failed to 
> write log event to MongoDB due to error: Timed out after 3 ms while 
> waiting to connect. Client view of cluster state is {type=UNKNOWN, 
> servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING}]
> {noformat}
> full log4j2.xml file
> {code:xml}
> 
> 
>   
> 
>   
> 
> 
>connection="${env:MONGO_LOG_URI:-mongodb://localhost:27017/log.mongo4test}" />
> 
>   
>   
> 
>   
>   
> 
> 
> 
>   
> 
> {code}
> build.gradle
> {code:groovy}
> plugins {
>   id 'org.springframework.boot' version '2.6.3'
>   id 'io.spring.dependency-management' version '1.0.11.RELEASE'
>   id 'java'
> }
> group = 'com.example'
> version = '0.0.1-SNAPSHOT'
> sourceCompatibility = '11'
> ext ['log4j2.version'] = '2.17.2-SNAPSHOT'
> repositories {
> mavenCentral()
> maven {
> url "http://repository.apache.org/content/repositories/snapshots/";
> }
> }
> dependencies {
>   implementation group: 'org.apache.logging.log4j', name: 
> 'log4j-mongodb4', version: '2.17.2-SNAPSHOT'
>   implementation 'org.springframework.boot:spring-boot-starter-web'
>   implementation 'org.springframework.boot:spring-boot-starter-log4j2'
>   testImplementation 'org.springframework.boot:spring-boot-starter-test'
> }
> configurations {
>   all {
>   exclude group: 'org.springframework.boot', module: 
> 'spring-boot-starter-logging'
>   exclude group: 'org.springframework.boot', module: 
> 'logback-classic'
>   }
> }
> tasks.named('test') {
>   useJUnitPlatform()
> }
> {code}
> is this normal behavior? I have tried to reproduce this without spring boot  
> without any success. 
> Any ideas?



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (LOG4J2-3396) ERROR Recursive call to appender mongodb with spring boot root logger

2022-02-08 Thread Omer U (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-3396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17488696#comment-17488696
 ] 

Omer U commented on LOG4J2-3396:


I've created a minimal project. Modified build.gradle and created log4j2.xml 
file.

[https://github.com/ugurlu/spring-boot-log4j2-mongo-test]

 

> ERROR Recursive call to appender mongodb with spring boot root logger
> -
>
> Key: LOG4J2-3396
> URL: https://issues.apache.org/jira/browse/LOG4J2-3396
> Project: Log4j 2
>  Issue Type: Question
>  Components: MongoDB
>Affects Versions: 2.17.1
>Reporter: Omer U
>Priority: Major
>
> If mongodb4 logger is used as root logger in basic spring boot rest 
> application, it causes some sort of recursion error. And stalls startup. 
>  below causes recursive call error
> {code:xml}
>  
>   
>   
>  
> {code}
> while following does not produce error
> {code:xml}
>   
> 
>   
> 
> 
>   
> 
> 
>   
> {code}
>  
> {noformat}
> 2022-02-07 23:35:43,487 cluster-ClusterId{value='620182632ff6a504abdb6699', 
> description='null'}-localhost:27017 ERROR Recursive call to appender mongodb
> 23:36:13.481 [st:27017] INFO  o.m.d.cluster - Cluster description not yet 
> available. Waiting for 3 ms before timing out
> 2022-02-07 23:36:13,480 
> cluster-rtt-ClusterId{value='620182632ff6a504abdb6697', 
> description='null'}-localhost:27017 ERROR Unable to write to database 
> [noSqlManager{ description=mongodb, bufferSize=0, provider=MongoDb4Provider 
> [connectionString=mongodb://localhost:27017/tombolog.mongo4test, 
> collectionSize=1073741824, isCapped=true, 
> mongoClient=com.mongodb.client.internal.MongoClientImpl@2f67a4d3, 
> mongoDatabase=com.mongodb.client.internal.MongoDatabaseImpl@5e3f861] }] for 
> appender [mongodb]. 
> org.apache.logging.log4j.core.appender.AppenderLoggingException: Failed to 
> write log event to MongoDB due to error: Timed out after 3 ms while 
> waiting to connect. Client view of cluster state is {type=UNKNOWN, 
> servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING}]
> {noformat}
> full log4j2.xml file
> {code:xml}
> 
> 
>   
> 
>   
> 
> 
>connection="${env:MONGO_LOG_URI:-mongodb://localhost:27017/log.mongo4test}" />
> 
>   
>   
> 
>   
>   
> 
> 
> 
>   
> 
> {code}
> build.gradle
> {code:groovy}
> plugins {
>   id 'org.springframework.boot' version '2.6.3'
>   id 'io.spring.dependency-management' version '1.0.11.RELEASE'
>   id 'java'
> }
> group = 'com.example'
> version = '0.0.1-SNAPSHOT'
> sourceCompatibility = '11'
> ext ['log4j2.version'] = '2.17.2-SNAPSHOT'
> repositories {
> mavenCentral()
> maven {
> url "http://repository.apache.org/content/repositories/snapshots/";
> }
> }
> dependencies {
>   implementation group: 'org.apache.logging.log4j', name: 
> 'log4j-mongodb4', version: '2.17.2-SNAPSHOT'
>   implementation 'org.springframework.boot:spring-boot-starter-web'
>   implementation 'org.springframework.boot:spring-boot-starter-log4j2'
>   testImplementation 'org.springframework.boot:spring-boot-starter-test'
> }
> configurations {
>   all {
>   exclude group: 'org.springframework.boot', module: 
> 'spring-boot-starter-logging'
>   exclude group: 'org.springframework.boot', module: 
> 'logback-classic'
>   }
> }
> tasks.named('test') {
>   useJUnitPlatform()
> }
> {code}
> is this normal behavior? I have tried to reproduce this without spring boot  
> without any success. 
> Any ideas?



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (LOG4J2-3396) ERROR Recursive call to appender mongodb with spring boot root logger

2022-02-07 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-3396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17488522#comment-17488522
 ] 

Gary D. Gregory commented on LOG4J2-3396:
-

Would you provide a PR on GitHub with a test that demonstrates this issue? That 
would be the simplest for me to debug.

> ERROR Recursive call to appender mongodb with spring boot root logger
> -
>
> Key: LOG4J2-3396
> URL: https://issues.apache.org/jira/browse/LOG4J2-3396
> Project: Log4j 2
>  Issue Type: Question
>  Components: MongoDB
>Affects Versions: 2.17.1
>Reporter: Omer U
>Priority: Major
>
> If mongodb4 logger is used as root logger in basic spring boot rest 
> application, it causes some sort of recursion error. And stalls startup. 
>  below causes recursive call error
> {code:xml}
>  
>   
>   
>  
> {code}
> while following does not produce error
> {code:xml}
>   
> 
>   
> 
> 
>   
> 
> 
>   
> {code}
>  
> {noformat}
> 2022-02-07 23:35:43,487 cluster-ClusterId{value='620182632ff6a504abdb6699', 
> description='null'}-localhost:27017 ERROR Recursive call to appender mongodb
> 23:36:13.481 [st:27017] INFO  o.m.d.cluster - Cluster description not yet 
> available. Waiting for 3 ms before timing out
> 2022-02-07 23:36:13,480 
> cluster-rtt-ClusterId{value='620182632ff6a504abdb6697', 
> description='null'}-localhost:27017 ERROR Unable to write to database 
> [noSqlManager{ description=mongodb, bufferSize=0, provider=MongoDb4Provider 
> [connectionString=mongodb://localhost:27017/tombolog.mongo4test, 
> collectionSize=1073741824, isCapped=true, 
> mongoClient=com.mongodb.client.internal.MongoClientImpl@2f67a4d3, 
> mongoDatabase=com.mongodb.client.internal.MongoDatabaseImpl@5e3f861] }] for 
> appender [mongodb]. 
> org.apache.logging.log4j.core.appender.AppenderLoggingException: Failed to 
> write log event to MongoDB due to error: Timed out after 3 ms while 
> waiting to connect. Client view of cluster state is {type=UNKNOWN, 
> servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING}]
> {noformat}
> full log4j2.xml file
> {code:xml}
> 
> 
>   
> 
>   
> 
> 
>connection="${env:MONGO_LOG_URI:-mongodb://localhost:27017/log.mongo4test}" />
> 
>   
>   
> 
>   
>   
> 
> 
> 
>   
> 
> {code}
> build.gradle
> {code:groovy}
> plugins {
>   id 'org.springframework.boot' version '2.6.3'
>   id 'io.spring.dependency-management' version '1.0.11.RELEASE'
>   id 'java'
> }
> group = 'com.example'
> version = '0.0.1-SNAPSHOT'
> sourceCompatibility = '11'
> ext ['log4j2.version'] = '2.17.2-SNAPSHOT'
> repositories {
> mavenCentral()
> maven {
> url "http://repository.apache.org/content/repositories/snapshots/";
> }
> }
> dependencies {
>   implementation group: 'org.apache.logging.log4j', name: 
> 'log4j-mongodb4', version: '2.17.2-SNAPSHOT'
>   implementation 'org.springframework.boot:spring-boot-starter-web'
>   implementation 'org.springframework.boot:spring-boot-starter-log4j2'
>   testImplementation 'org.springframework.boot:spring-boot-starter-test'
> }
> configurations {
>   all {
>   exclude group: 'org.springframework.boot', module: 
> 'spring-boot-starter-logging'
>   exclude group: 'org.springframework.boot', module: 
> 'logback-classic'
>   }
> }
> tasks.named('test') {
>   useJUnitPlatform()
> }
> {code}
> is this normal behavior? I have tried to reproduce this without spring boot  
> without any success. 
> Any ideas?



--
This message was sent by Atlassian Jira
(v8.20.1#820001)