Skip to content

ERROR [MongoDBAppender] - Value cannot be null #54

@mwcoope

Description

@mwcoope

So I have multiple projects deployed to a single server using log4mongo and all with seemingly the same configuration, but a couple applications are logging successfully while others are not. They are receiving the following error as output from the internal.debug setting for log4net:

log4net:ERROR [MongoDBAppender] ErrorCode: GenericFailure. Failed in DoAppend
System.ArgumentNullException: Value cannot be null.
Parameter name: value
   at MongoDB.Bson.BsonDocument.Add(String name, BsonValue value)
   at Log4Mongo.BackwardCompatibility.BuildBsonDocument(LoggingEvent loggingEvent)
   at Log4Mongo.MongoDBAppender.BuildBsonDocument(LoggingEvent log)
   at Log4Mongo.MongoDBAppender.Append(LoggingEvent loggingEvent)
   at log4net.Appender.AppenderSkeleton.DoAppend(LoggingEvent loggingEvent)

Web.config

<configuration>
...
<log4net>
    <appender name="MongoDBAppender" type="Log4Mongo.MongoDBAppender, Log4Mongo">
      <connectionStringName value="MongoConnectionString" />
      <collectionName value="logs" />
    </appender>
    <root>
      <level value="ALL" />
      <appender-ref ref="MongoDBAppender" />
    </root>
  </log4net>
...
</configuration>

Where MongoConnectionString is a valid connectionsting. Using the standard document logging, it appears that some field it is trying to access is missing a value, and therefore failing.

When I debug my project locally, the logs are written successfully.

Am I missing something here? How can I know what value is null/missing? What standard document fields could be the issue here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions