2

The EventLogFactory is writing Information logs for every DEBUG statement from OrmLite or Redis, simply from this one line of code:

LogManager.LogFactory = new EventLogFactory("MyApplication");

For example:

An error occurred in the application: MyApplication
Exception: DEBUG: SELECT "Id", "Name" FROM "MyTable"

An error occurred in the application: MyApplication
Exception: DEBUG: S: GET urn:iauthsession:upuuVGyYt48yoMYjdaBB

This service handles thousands of Redis operations per minute, so logging all these is cumbersome.

This happens even if I do not add any ServiceExceptionHandlers or UncaughtExceptionHandlers; I do not have any of my own logging code active.

I saw that the EventLogFactory sets its IsDebugEnabled flag to true, but I couldn't find any relevant place that it is referenced in the source. Nonetheless, I tried adding this (redundant) line, to no effect:

SetConfig(new HostConfig { DebugMode = false });

How do I prevent these DEBUG logs?

0

2 Answers 2

1

I've just modified the EventLogFactory constructor to accept a debugEnabled:false property which will prevent logging debug messages with:

LogManager.LogFactory = new EventLogFactory("MyApplication", debugEnabled:false);

This change is available from v4.0.41+ of ServiceStack that's now available on MyGet.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks in advance, but right now the MyGet feed is missing the main ServiceStack package. :)
@FacioRatio hmm apologies, just re-published the latest packages to MyGet.
No worries. Your patch is much appreciated! Everything works as expected.
1

As far as I know Event Log does not offer much control over logging.

However, if you were willing to switch to NLog it's pretty trivial. You just need to add a rule to the config to set the minimum level to Info:

<logger name="*" minlevel="Info" writeTo="file" />

1 Comment

Thank you for the NLog suggestion. I will prototype it as part of a larger logging initiative in the near future.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.