I am developing a software package (it will include several programs, in the future it is possible to expand the complex by adding new programs) and the question arose about the file format for logs. The project is written in C #.

Programs from the complex will keep logs of their work. It seems to be nothing special, but I’ve conceived such a thing: in order not to dig into the logs, not to look for what we say on Friday the 13th at 13:13:13, I decided to create a separate program (something like the log parser) that will parse the logs, search for the necessary information for the specified date and time period, and so on. There was a question about how to organize logs: in the form of files or databases with separate tables for each program.

I am at a crossroads: on the one hand, text files are convenient, it will only be necessary to develop your own format. XML files are a great option for this purpose. On the other hand, one database, but a bunch of tables, moreover, is not very happy with the prospect of creating a new table each time (when adding a new program to the complex). But SQL is behind the database, i.e. I will be able to more easily implement the idea with this logger parser.

In general, I tend to the files. Maybe there is a more flexible solution or someone faced with a similar task?

UPD

When the file system logs - every day a new file (for example, calling the file on 03/04/2013 (Monday), tomorrow will be 03/05/2012 (Tuesday), etc.), respectively. the files will be small, and the database will eventually grow and become thick. Number of files will also grow.

  • It is possible to use a ready-made log framework. or you can create a label like: id, time, program_id (fk to programs table), level, message - jmu
  • for example, log4net, did you mean that? - ghost rider
  • yes, this one - jmu
  • good thing, but not very suitable for my purposes - ghost rider
  • decided to use SQLite for these purposes - ghost rider

2 answers 2

And why for each program a new table of logs? In one way or something not to cram?

Make there just 1 field, which will take the value of the program or the new module.

Why invent something new every time? 1 table a few fields and all.

// upd

pyff

When the file system logs - every day a new file (for example, calling the file on 03/04/2013 (Monday), tomorrow will be 03/05/2012 (Tuesday), etc.), respectively. the files will be small, and the database will eventually grow and become thick. Number of files will also grow.

WTF ???

Do you understand what you wrote? The database will grow, and the files will be small. But what is the formal difference between them? 3-5 bytes?

Try to do a search in the files then for March 12, 2012 in the period from 10:03 to 23:44

Quickly find the data?

  • @Shrek do not want to dump everything in one table - ghost rider
  • What are the difficulties? and the second question, why have extra log tables, if they are identical? - Artem
  • those. You propose to create one table for example of the following type: Name | Programs | Data Messages | Text Messages, and let all programs break into it, writing data. And when you enter a new program, throw ALTER TABLE into battle - ghost rider
  • Yes exactly. This is a complex of programs, they should work together somehow. Or is the logic of this complex different? - Artem
  • You + to the answer, thank you very much! However, I still experiment and see if anyone else can speak on this issue - ghost rider

And I don’t catch up with anything - why such a program? There is, after all, Log4Net - made on the basis of the de facto industry standard for Java logging - Log4J.

Appender it Appender , which writes logs to the database and that's it. For example, I do not see what is bad AdoNetAppender

Or am I wrong in something?