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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:24:06+00:00 2026-06-05T18:24:06+00:00

http://logging.apache.org/log4net/release/config-examples.html Given the log table here: CREATE TABLE [dbo].[Log] ( [Id] [int] IDENTITY (1,

  • 0

http://logging.apache.org/log4net/release/config-examples.html

Given the log table here:

CREATE TABLE [dbo].[Log] (
    [Id] [int] IDENTITY (1, 1) NOT NULL,
    [Date] [datetime] NOT NULL,
    [Thread] [varchar] (255) NOT NULL,
    [Level] [varchar] (50) NOT NULL,
    [Logger] [varchar] (255) NOT NULL,
    [Message] [varchar] (4000) NOT NULL,
    [Exception] [varchar] (2000) NULL,

    [Product] [varchar] 100 not null
)

and the appender config here:

<appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
    <bufferSize value="100" />
    <connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    <connectionString value="data source=[database server];initial catalog=[database name];integrated security=false;persist security info=True;User ID=[user];Password=[password]" />
    <commandText value="INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message],[Exception], [Product]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception, @product)" />
    <parameter>
        <parameterName value="@log_date" />
        <dbType value="DateTime" />
        <layout type="log4net.Layout.RawTimeStampLayout" />
    </parameter>
    <parameter>
        <parameterName value="@thread" />
        <dbType value="String" />
        <size value="255" />
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%thread" />
        </layout>
    </parameter>
    <parameter>
        <parameterName value="@log_level" />
        <dbType value="String" />
        <size value="50" />
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%level" />
        </layout>
    </parameter>
    <parameter>
        <parameterName value="@logger" />
        <dbType value="String" />
        <size value="255" />
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%logger" />
        </layout>
    </parameter>
    <parameter>
        <parameterName value="@message" />
        <dbType value="String" />
        <size value="4000" />
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%message" />
        </layout>
    </parameter>
    <parameter>
        <parameterName value="@exception" />
        <dbType value="String" />
        <size value="2000" />
        <layout type="log4net.Layout.ExceptionLayout" />
    </parameter>
</appender>

How can I add a constant parameter for the “product” column- without any code changes? Config-only change if possible!

For example, I want to do something like this:

<parameter>
    <parameterName value="@product" />
    <dbType value="String" />
    <size value="100" />

    <constantValue value="Product A" /> <!-- how do i do this? -->

</parameter>

EDIT: The answer is simple. Edit the command text!

<commandText value="INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message],[Exception], [Product]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception, 'Product A')" />
  • 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-06-05T18:24:08+00:00Added an answer on June 5, 2026 at 6:24 pm

    While you could simply add a ‘SomeConstant’ value to the insert statement, we use the following method with the AdoNetAppender. We add a @source column to our log table so we can have many servers all logging to the same table, yet give us some SYSLOG like functionality.

      ...
      <commandText value="INSERT INTO Log ([Date],[Source],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @source, @log_level, @logger, @message, @exception)" />
    
      ...
      <parameter>
        <parameterName value="@source"/>
        <dbType value="String"/>
        <size value="32"/>
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="WEB1"/>
        </layout>
      </parameter>
    

    The PatternLayout readily accepts string constants, why complicate it!

    Enjoy.

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

Sidebar

Related Questions

http://logging.apache.org/chainsaw/quicktour.html First feature. I completed the tutorial, it simply showed how to visually use
When I build the log4cxx on Visual 2005 according to instructions http://logging.apache.org/log4cxx/building/vstudio.html , I
I just read some source code is from org.apache.cxf.common.logging.JDKBugHacks and also in http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java .
From here: http://google-glog.googlecode.com/svn/trunk/doc/glog.html Debug Mode Support Special debug mode logging macros only have an
I have: ubuntu-9.10-desktop-amd64 + NetBeans6.7.1 I just downloaded Commons HttpClient 3.1 (legacy) from http://hc.apache.org/downloads.cgi
The samples and documentation in question can be found here: http://static.springsource.org/spring-flex/docs/1.5.0.M1/ The reference doc
Ive followed this tutorial to install (multiple) solr instances on tomcat http://wiki.apache.org/solr/SolrTomcat Now i
http://jsbin.com/uxepap/3/edit Here is div with links inside. I'm trying to replace comma inside last
I've recently checked out Apache Chainsaw as a viewer for my log4net logs. One
Trying to run the basic examples given by playn, wanting to have a go

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.