1

I'm tasked of introducing logging to a larger project. I have the following requirements:

  • Logging to the same file must be enabled from Visual Studio's C++ products, C# products, desktop apps, windows services, and more than one process should be able to write to a log file at once.
  • Format of logs is custom (semi-colon delimited fields, something like "custom_date;custom_time;the_rest;of_the_fields").
  • Log files have limit in size.
  • There's main .log file and older .bak file. .bak file is deleted when new .log file is created and current .log is renamed to .bak.
  • In one special case name of log files depends on time of creation. There are no multi-process writes in this case.

Now, I can roll my own implementation, but it would be really nice if there are ready made free libraries that satisfy all of the requirements. Does any one know of such libraries?

Dialecticus
  • 16,400
  • 7
  • 43
  • 103

5 Answers5

1

Many of your requirements (I think all but the language independence) are fulfilled by log4net

As you want to use several software components to use the logger I would suggest to write a windows service by yourself as it can be used by all types of your client software (C++, C#, ...)

MatthiasG
  • 4,434
  • 3
  • 27
  • 47
  • 1
    The language independence requirement can also be met by doing some googling: http://blogs.artinsoft.net/Mrojas/archive/2008/06/19/Log4NET-for-C++.aspx – M.Babcock Dec 28 '11 at 16:12
1

Maybe you could simply write to the Event Log.

ken2k
  • 48,145
  • 10
  • 116
  • 176
0

Use Microsoft's Enterprise Exception and Logging Application blocks. It satisfies all of your requirements. Everything is configurable using the web.config or app.config and allows the use of templates to record specific details. Also note that Microsoft has included a rolling type logger that will automatically start a new file based upon size or date/time. It's a complete package for any type of logging you want to do, MSMQ, SQL, flat file, windows event log, etc.

Chris Gessler
  • 22,727
  • 7
  • 57
  • 83
0

I would recommend NLog, meets most of your requirements

Emmanuel N
  • 7,350
  • 2
  • 26
  • 36
  • Since word on the street is that NLog is preferable to log4net and Enterprise Library, I think I'll go with it. – Dialecticus Dec 29 '11 at 11:04
0

Log4Net can help you with your 2 and 3 point, for your 1,4 and 5 point i suggest you write a WebService that do all the work for writting in the logs, create, delete, etc.

Piyey
  • 473
  • 5
  • 15