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 6736067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:05:11+00:00 2026-05-26T11:05:11+00:00

I am using the latest version of NLog ( from nuget ) and I

  • 0

I am using the latest version of NLog ( from nuget ) and I configure it programmatically.
Currently it saves in my database but I would like it to encrypt my stacktrace parameter.

Is there any way that NLog does this automatically?
Given that I have a simple function to encrypt the stacktrace is there an easy way to apply it?

  • 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-26T11:05:12+00:00Added an answer on May 26, 2026 at 11:05 am

    I would suggest writing a LayoutRendererWrapper. A LayoutRendererWrapper allows you to “wrap” a LayoutRenderer so that you can apply processing to the output. In the case of encrypting the stack trace, you can configure NLog to add the StackTrace to the output, but you can wrap the StackTrace layout renderer so that you can apply your encryption.

    You see examples of LayuoutRendererWrappers in NLog’s source code repository.

    Actually, the general nature of the LayoutRendererWrapper means that you can write an encrypting wrapper and apply it to any LayoutRenderer. So, you could, for example, encrypt the stack trace and the message, but leave the rest of the fields as clear text.

    Here is an example (untested) of how you might write an encrypting LayoutRendererWrapper:

    namespace NLog.LayoutRenderers.Wrappers
    {
      using System.ComponentModel;
      using System.Globalization;
      using NLog.Config;
    
      [LayoutRenderer("Encrypt")]
      [AmbientProperty("Encrypt")]
      [ThreadAgnostic]
      public sealed class EncryptLayoutRendererWrapper : WrapperLayoutRendererBase    
      {
        public EncryptLayoutRendererWrapper()
        {
          this.Culture = CultureInfo.InvariantCulture;
          this.Encrypt = true;
        }
    
        [DefaultValue(true)]
        public bool Encrypt { get; set; }
    
        public CultureInfo Culture { get; set; }
    
        protected override string Transform(string text)
        {
          return this.Encrypt ? Encrypt(text) : text;
        }
    
        protected string Encrypt(string text)
        {
          //Encrypt your text here.
        }
      }
    }
    

    I think it would be configured like this in the NLog.config file:

    ${longdate} | ${logger} | ${level} | ${encrypt:${stacktrace}} | ${message}
    

    I’m not sure how you would configure it programmatically as I don’t normally use programmatic configuration.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently using the latest version of ggplot2 from github. In version 0.8.9
Hello i am using the latest version of artoolkit, and succesfully compiled simplevrml, but
I am using wordpress latest version. Currently my blog is set to custom permalink
I am currently building an Excel 2007 Add-in using VSTO (latest version + sp1)
I'm using derived tables (latest version of MySQL) to get counts and data from
I am using the latest version of jqGrid : 3.6.4 This seems like a
I'm using the latest version of Google App Engine, Python 2.7 and webapp2, but
Im using latest TCPDF version(5.9). But have some strange problems with encoding. I need
i am using the latest version of tweetsharp from their site (TweetSharp.Next - Version
Scenario I am using the latest version of DevExpress XtraGrid. I am currently binding

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.