I have a application where I am using logging for the app, but I also want to do an audit log to the sql server. I was going to use tagging to specify what I want to log to the sql server, but how do I add a custom column / field to specify the user of said log entry? I have columns for timestamp, tag, level and message but I also have a column for user. what do I put into the "writer.field.user = ???" to specify what I want that column to have? This would be the same value for each instance and duration of the app when they log in. I have TinyLog v2.6.2. Thanks!
1
There are 1 best solutions below
Related Questions in TINYLOG
- How to configure tinylog with rolling files in java using Netbeans or Eclipse?
- Custom field in IDBC writer?
- Rolling file in Tinylog overwrites a log file on every app start
- tinylog2 makes error log but does not make or maintain debug log
- Tinylog 2 - setting an absoute file path for log files
- How to redirect System.out and System.err to tinylog logger?
- Ability to apply specific tinylog writer
- Output Liquibase log through TinyLog
- How to write rolling file to user.home directory
- Tinylog Android, VerifyError exception
- How can i get the current log file name on runtime from tinylog
- Tinylog Android, is it possible to clear the file?
- In graalvm, how to load tinylog.properties with native-image?
- In TinyLog what is the platform independent format character for new line in tinylog.properties
- Proguard obfuscation fails with tinylog
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
For your use case, I suggest to use context values for your custom fields. For example, when the user logs in, you can store the user name via
ThreadContext.put("user", name).Afterwards, all log entries, which are issued by the same thread or of one of its child thread, will be enriched by the stored context values. You can use the placeholder
{context: key}for assigning context value to SQL table fields. If you have stored the user name with the keyuserin the thread context, you can assign it viawriter.field.user = {context: user}".If you use a thread pool or if you reuse threads for different users, you have to take care of clearing the thread context before reusing a thread.