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

Gary Gregory edited comment on LOG4J2-403 at 5/22/15 5:35 AM:
--------------------------------------------------------------

In 
{{org.apache.logging.log4j.nosql.appender.mongodb.MongoDbProvider.createNoSqlProvider(...)}}
 code I see:

{code:java}
...
        if (!database.isAuthenticated()) {
            if (username != null && username.length() > 0 && password != null 
&& password.length() > 0) {
                description += ", username=" + username + ", passwordHash="
                        + NameUtil.md5(password + 
MongoDbProvider.class.getName());
                MongoDbConnection.authenticate(database, username, password);
            } else {
                LOGGER.error("The database is not already authenticated so you 
must supply a username and password "
                        + "for the MongoDB provider.");
                return null;
            }
        }
..
{code}

To solve this issue, the else would look like:

{code:java}
                LOGGER.warn("The database is not already authenticated so you 
must supply a username and password "
                        + "for the MongoDB provider.");
{code}

Note that I changed the {{error}} to a {{warn}} and the {{return null;}} has 
been removed.

Thoughts? Who can test this?



was (Author: garydgregory):
In 
{{org.apache.logging.log4j.nosql.appender.mongodb.MongoDbProvider.createNoSqlProvider(...)}}
 code I see:

{code:java}
...
        if (!database.isAuthenticated()) {
            if (username != null && username.length() > 0 && password != null 
&& password.length() > 0) {
                description += ", username=" + username + ", passwordHash="
                        + NameUtil.md5(password + 
MongoDbProvider.class.getName());
                MongoDbConnection.authenticate(database, username, password);
            } else {
                LOGGER.error("The database is not already authenticated so you 
must supply a username and password "
                        + "for the MongoDB provider.");
                return null;
            }
        }
..
{code}

To solve this issue, the else would look like:

{code:java}
                LOGGER.warn("The database is not already authenticated so you 
must supply a username and password "
                        + "for the MongoDB provider.");
{code}

Note that the {{return null;}} has been removed.

Thoughts? Who can test this?


> MongoDB appender, username and password should be optional.
> -----------------------------------------------------------
>
>                 Key: LOG4J2-403
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-403
>             Project: Log4j 2
>          Issue Type: Improvement
>          Components: Appenders
>    Affects Versions: 2.0-beta9
>            Reporter: Poorna Subhash P
>            Priority: Minor
>
> In development environments it is usual to create MongoDB without any 
> users/restrictions. 
> In MongoDB appender if I don't provide usrname,password or if I provide empty 
> values, its throwing exception even without attempting for connection. 
> Getting following error:  ERROR The database is not already authenticated so 
> you must supply a username and password for the MongoDB provider.
> It would be nice if there is an ability to connect to MongoDB without user 
> details (making them optional fields).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to