Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6167343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:29:44+00:00 2026-05-23T22:29:44+00:00

I have a database I’m trying to write my messages to and would like

  • 0

I have a database I’m trying to write my messages to and would like to use the ${level} layout, but I need to translate it to the int value for reference to my own table that stores logging levels. Is it possible to maybe cast the level to my enum in config? Any other ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T22:29:45+00:00Added an answer on May 23, 2026 at 10:29 pm

    I have not checked this, but I suspect you should be able to just write your own layout renderer (plugin) for NLog to do what you want to do. NLog is very pluggable 🙂

    A quick example of how a layout renderer could look (not tested…):

    [LayoutRenderer("intLevel", UsingLogEventInfo = true)]
    public class IntLevel : LayoutRenderer
    {
        protected override int GetEstimatedBufferSize(LogEventInfo logEvent)
        {
            return 1;
        }
    
        protected override void Append(StringBuilder builder, LogEventInfo logEvent)
        {
            switch(logEvent.Level.LowercaseName)
            {
                case "trace":
                    builder.Append(0);
                    break;
                case "debug":
                    builder.Append(1);
                    break;
                case "info":
                    builder.Append(2);
                    break;
                case "warn":
                    builder.Append(3);
                    break;
                case "error":
                    builder.Append(4);
                    break;
                case "fatal":
                    builder.Append(5);
                    break;
                default:
                    builder.Append(-1);
                    break;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have database setup like so: CREATE TABLE `article` ( `id` int(11) NOT
I have database A and database B. I would like to do one way
I have database application on Android device. I would like to have a possibility
I have Database with date field. I see the time like: 1900-01-01 13:38:00.000 How
i have database table like this +-------+--------------+----------+ | id | ip | date |
I have database handle in channelMap (for 1 connection for all messages) and I
I have database with schema on picture below and I need to select everything
Hi i have database like this Users Table user_id | username | branch_id(foreignkey)| Approved_id(foreignkey)
i have database table with few text fields which i use to filter data
I have database table but without the index, and I want to add index

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.