Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can define the localised strings in your database and just log the id of the log message to your log table. The log messages table would also contain a field to indicate the language.</p> <p>If you are doing a lot of logging, that would also reduce the size of your log (even though that is probably not relevant, given the storage space available in modern computers ;-)</p> <p>That method has two problems:</p> <ol start="2"> <li>You need to synchronise the logging in your application with your log message table. </li> <li>You can not log any dynamic data, e.g. the customer's name.</li> </ol> <p>The first point can be dealt with by using an enum with descriptive names, e.g.</p> <pre><code>enum LogMessages { OutOfDiskSpace = 1; OutOfMemory = 2; OutOfCoffee = 3; } </code></pre> <p>In your app you would call <code>void LogToDatabase(LogMessages)</code> like this:</p> <pre><code>// forgot to buy coffee again! Log(OutOfCoffee); </code></pre> <p>The second problem needs more work. You could define your strings so that you could use <code>string.Format()</code>: </p> <pre><code> string.format("{0} forgot to buy coffee again. Lazy geek!", "I"); // yields: "I forgot to buy coffee again. Lazy geek!" </code></pre> <p>For this you have to store the variation data ("I", "you", "My little brother"...) in you log table together with the log message ID. (Or you normalise it a little more and put it in a third table, but that could very well be premature normalisation ;-).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload