Bill,

Long pattern names like %property require version 1.2.9. Can you retest this 
using 1.2.9?
There are a number of permission restrictions that may prevent log4net from 
finding the machine name, however that is unlikely to be the case.

If you are using 1.2.9 and you want to expose your own machine identifier you 
can set the value of a property programmatically during your application 
startup. Something like this:

log4net.GlobalContext.Properties["host"] = Environment.MachineName; /* Or your 
own value here */

Then you should be able to log the value to the database as follows:

<parameter>
  <parameterName value="@machine_name" />
  <dbType value="String" />
  <size value="50" />
  <layout type="log4net.Layout.PatternLayout" value="%property{host}" />
</parameter>

Nicko

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] 
> Sent: 21 April 2005 10:19
> To: [email protected]
> Subject: RE: Machine name
> 
> This doesn't appear to work unfortunately.  In my .config file I have:
> 
>             <param name="Parameter">
>                 <param name="ParameterName" value="@machine_name" />
>                 <param name="DbType" value="String" />
>                 <param name="Size" value="50" />
>                 <param name="Layout" 
> type="log4net.Layout.PatternLayout">
>                     <param name="ConversionPattern"
> value="%P{log4net:HostName}" />
>                 </param>
>             </param>
> 
> (for some reason "%property{log4net:HostName}" was giving me 
> WARNroperty{log4net:HostName} in the database as it didn't 
> seem to work out the that the p was part of a word and 
> treated is as a "level" directive)
> 
> If I change the value to a string literal, it appears in the 
> database, so I assume it's something to do with the actual 
> property.  I've also tried
> putting:
> 
> <property name="Machine" value="MyServer" />
> 
> in the root of the <log4net> node and setting the conversion 
> pattern to "%P{Machine}" but this also writes an empty column 
> to the database.
> 
> Any pointers?
> 
> Cheers,
> 
> Bill
> 
> 
>  -----Original Message-----
> From:         Helbig, Dirk (EXTERN: HUD) 
> [mailto:[EMAIL PROTECTED]
> 
> Sent: 21 April 2005 08:57
> To:   'Log4NET User'
> Cc:   Bill Martin
> Subject:      AW: Machine name
> 
> Hi,
> 
> we use this pattern in our environments:
> 
> %property{log4net:HostName}
> 
> I hope I could help you.
> 
> Dirk
> 
> -----Urspr�ngliche Nachricht-----
> Von: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Gesendet: Donnerstag, 21. April 2005 09:44
> An: [email protected]
> Betreff: Machine name
> 
> 
> I may be being dumb here, but I can't see any way of getting 
> hold of the
> machine name that an event is being logged from.
> 
> I have multiple machines in a cluster using an ADOAppender to 
> write to a
> common database, and I want to write a column with the 
> machine name in it.
> Is there a simple way to get hold of the name?
> 
> Cheers,
> 
> Bill
> 
> 
>  -----Original Message-----
> From:         Nicko Cadell [mailto:[EMAIL PROTECTED] 
> Sent: 18 April 2005 10:22
> To:   Log4NET User
> Subject:      [Maybe Spam] RE: Problem with headers and 
> footers in beta
> 1.2.9
> 
> You need to use XML numeric character references:
> 
> \r = &#xD;
> \n = &#xA;
> 
> Therefore \r\n becomes &#xD;&#xA; in XML.
> 
> Or alternatively you can use the PatternString type to expand 
> patterns in
> the header value, e.g.:
> 
> <header type="log4net.Util.PatternString" value="START pid=%processid
> date=%date %newline" />
> 
> Cheers,
> 
> Nicko
> 
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> > Sent: 18 April 2005 09:18
> > To: [email protected]
> > Subject: Problem with headers and footers in beta 1.2.9
> > 
> > Hello,
> > 
> > Last week, I downloaded the new 1.2.9 beta version and I
> > started to convert one of my projects in order to use it.
> > 
> > But, now, as announced in the Breaking Changes list, C style
> > escape sequences are not supported any more.
> > 
> > So far so good, but... With the previous versions, in the
> > Header and Footer parameters, I added \\\"\\\\r\\\\n\\\" at 
> > the end of the line in order to avoid the first line of the 
> > log to be appended to the header line.
> > 
> > Now that C style escape sequences are not translated, I
> > cannot find how to force a new line at the end of the header 
> > line. (I tried to add %newline as it can be done in the 
> > ConversionPattern, but, as I could expect, it doesn't work 
> > because there is no pattern interpretation in the Header and 
> > Footer parameters.
> > 
> > Therefore, is this a bug or is there another way to do it ?
> > 
> > By the way, congratulation for you excellent work. Log4net as
> > already saved me hours of work. It's so easy to integrate it 
> > in a p! roject !
> > 
> > Stephane Corteel
> > Technical and R&D Director
> > ASK sa
> > www.ask.be
> > 
> > 
> > 
> 
> 
> 
> 
> UK businesses use 2 million tonnes of paper each year.
> THINK before you PRINT this email.
> ______________________________________________________________
> 
> CONFIDENTIALITY NOTICE
> 
> This communication and the information it contains is intended for the
> person or organisation to 
> whom it is addressed.  Its contents are confidential and may 
> be protected in
> law.  Unauthorised use,  copying or disclosure of any of it 
> may be unlawful.
> If you are not the intended recipient, please 
> contact us immediately.
> 
> The contents of any attachments in this e-mail may contain 
> software viruses,
> which could damage your 
> own computer system.  While Marlborough Stirling has taken 
> every reasonable
> precaution to minimise 
> this risk, we cannot accept liability for any damage, which 
> you sustain as a
> result of software 
> viruses.  You should carry out your own virus checking 
> procedure before
> opening any attachment.
> 
> Marlborough Stirling plc, Registered in England and Wales 
> Registered No. 3008820,
> Jessop House, Jessop Avenue, Cheltenham, Gloucestershire, GL50 3SH
> Tel: 01242 547000     Fax: 01242 547100
> http://www.marlborough-stirling.com
> 
> 
> 

Reply via email to