I am quite a new comer to SQL Server and wondered exactly what the distinction between the SQL Server log is along with a custom log (during my situation, using log4net)? I suppose there's more choice on which to log using log4net, but what situations are instantly drenched through the database? For instance, if your user subscribes to my website, would I must by hand log that transaction, or would that be recorded within the database's log instantly? I am presently beginning a task and want to determine precisely what I ought to bother logging.


Apples and Oranges.

Log4net along with other custom 'logging' is simply a method to capture occasions a credit card applicatoin is confirming. 'Log' within this context reffers to whatever store can be used with this infrastucture to persist details about these occasions.

The database log however is one thing compeltely different. To be able to maintain consistency and atomicity databases make use of a so known as Write-Ahead-Log protocol. In WAL all changes are first durable written right into a journal, or log, prior to being put on the information. This enables recovery to replay the log (the journal) and obtain the information back to a regular condition, by moving back any uncommited work.

Database logs have practically nothing related to the application code. Any database update is going to be instantly drenched through the engine, simply since this is how data is up-to-date inside a database. You can't modify that, nor have you got any use of what's designed in the log (as it happens you are able to consider the log, however, you will not find any helpfull information for the application).

SQL log handles tansaction logging for moving back or comiting data. They're usually only worked with by somebody that knows what they're doing rebuilding backup copies or shipping the logs for backup copies.

The log4net along with other logging framweworks handle in code logging of exceptions, warning, or debug level info that you'd like to output for your own personel info. They may be delivered to a table inside a database, command window, flat file or web service. Common logging situations are catching unhandled exceptions in the application level to assist find bugs, or perhaps in any try catch claims writing the stack trace.

It monitors the transactions therefore it can roll it well or replay just in case of the crash. Quite more involved than simple logging.

The 2 are almost completely unrelated.

A database log can be used to rollback transactions, get over crashes, etc. Great items to ensure database consistency. It's updates/card inserts/removes inside it--not necessarily anything about intent or what your application is trying to complete unless of course it directly affects data within the database.

The applying log however (with Log4Net) could be very helpful when building and debugging the application. It's driven by you and really should contain information that traces what your application does. This really is something which can securely be switched off or reduced (by toggling the log level) whenever you no more require it.

The SQL Server log file is really employed for maintaining it's own stability, but it is not terribly helpful for normal designers. It isn't what you believe (and that i things i thought), a listing of SQL claims which have been run. It is a propriety format made to help SQL get over an accident or roll back transactions.

If you want to track what's happening within the system, the SQL transaction log will not be useful, and it might be tough to have that information out. Rather, I recommend adding triggers in your tables that write information off and away to another table, or then add code inside your data layer that saves off a log of what's happening. It may be as easy as wrapping the SQL command object with your personal implementation, which saved SQL claims off and away to log4net additionally to whatever normal code it had been performing.

It's the mechanism through which the RMDBS can assure atomicity and consistency, see ACID.