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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:41:03+00:00 2026-05-14T06:41:03+00:00

I am working with a log file and I have a method which is

  • 0

I am working with a log file and I have a method which is creating a generic entry in to the log. The generic log entry looks like this:

public StringBuilder GetLogMessage(LogEventType logType, object message)
{
        StringBuilder logEntry = new StringBuilder();
        logEntry.AppendFormat("DATE={0} ", DateTime.Now.ToString("dd-MMM-yyyy", new CultureInfo(CommonConfig.EnglishCultureCode)));
        logEntry.AppendFormat("TIME={0} ", DateTime.Now.ToString("HH:mm:ss", new CultureInfo(CommonConfig.EnglishCultureCode)));
        logEntry.AppendFormat("ERRORNO={0} ", base.RemoteIPAddress.ToString().Replace(".", string.Empty));
        logEntry.AppendFormat("IP={0}", base.RemoteIPAddress.ToString());
        logEntry.AppendFormat("LANG={0} ", base.Culture.TwoLetterISOLanguageName);
        logEntry.AppendFormat("PNR={0} ", this.RecordLocator);
        logEntry.AppendFormat("AGENT={0} ", base.UserAgent);
        logEntry.AppendFormat("REF={0} ", base.Referrer);
        logEntry.AppendFormat("SID={0} ", base.CurrentContext.Session.SessionID);
        logEntry.AppendFormat("LOGTYPE={0} ", logType.ToString() );
        logEntry.AppendFormat("MESSAGE={0} ", message);
        return logEntry;
}

What would be the best approach for adding additional parameters before “MESSAGE=”? For example if I wanted to add “MODULE=” from a derived class when the GetLogMessage is being run. Would a delegate be what I am looking for or marking the method as virtual and overriding it or do I need something entirely different?

Any help would be appreciated.

  • 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-14T06:41:03+00:00Added an answer on May 14, 2026 at 6:41 am

    What about this approach:

    public StringBuilder GetLogMessage(LogEventType logType, object message)
    {
        return GetLogMessage(logType, message, null);
    }
    
    public StringBuilder GetLogMessage(LogEventType logType, object message, Dictionary<string,string> extraParameters) 
    { 
            StringBuilder logEntry = new StringBuilder(); 
            logEntry.AppendFormat("DATE={0} ", DateTime.Now.ToString("dd-MMM-yyyy", new CultureInfo(CommonConfig.EnglishCultureCode))); 
            logEntry.AppendFormat("TIME={0} ", DateTime.Now.ToString("HH:mm:ss", new CultureInfo(CommonConfig.EnglishCultureCode))); 
            logEntry.AppendFormat("ERRORNO={0} ", base.RemoteIPAddress.ToString().Replace(".", string.Empty)); 
            logEntry.AppendFormat("IP={0}", base.RemoteIPAddress.ToString()); 
            logEntry.AppendFormat("LANG={0} ", base.Culture.TwoLetterISOLanguageName); 
            logEntry.AppendFormat("PNR={0} ", this.RecordLocator); 
            logEntry.AppendFormat("AGENT={0} ", base.UserAgent); 
            logEntry.AppendFormat("REF={0} ", base.Referrer); 
            logEntry.AppendFormat("SID={0} ", base.CurrentContext.Session.SessionID); 
            logEntry.AppendFormat("LOGTYPE={0} ", logType.ToString() ); 
            if(extraParameters != null)
            {
                 foreach(var s in extraParameters.Keys)
                 {
                      logEntry.AppendFormat("{0}={1} ", s, extraParameters[s] ); 
                 }
            }
            logEntry.AppendFormat("MESSAGE={0} ", message); 
            return logEntry; 
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a method that writes to a log file. If the file exists
I'm working on implementing a reasonably simple XML serializer/deserializer (log file parser) application in
Part of an app I am working on includes a log file viewer, with
I'm working on implementing a log based file system for a file as a
We're working on a Log Viewer. The use will have the option to filter
I've been working on a log viewer for a Rails app and have found
I have a Winforms application which is working fine.. using a BackgroundWorkerThread to manage
On a current project which I'm currently working, i have a symfony task that
I am working for a log analyzer system,which read the log of tomcat and
I have the following Method. In the fileschooser I can select a file or

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.