
|
If you were logged in you would be able to see more operations.
|
|
|
|
Issue Links:
|
Incorporates
|
|
This issue incorporates:
|
|
LOG4NET-53
Allow repository properties to be set in the config file
|
|
|
|
|
|
|
|
| Resolution Date: |
13/Jan/08 06:48 PM
|
|
It would be useful if the user was able to supply additional properties to the <convert> tag in the form of:
<property name="foo" value="bar" />
<property name="Hello" value="World" />
The code below uses a <property> node to determine if the HomeAddress or the WorkAddress will appear in the log message. If the parameter is not present, the converter prints a default value.
<converter>
<name value="user-converter" />
<type value="Company.Project.Logging.UserConverter, Company.Project" />
<property name="Address" value="HomeAddress" />
</converter>
<conversionPattern value="%p %d %user-converter{Nicko} - %m%n" />
The <property> tags would be accessible via a Properties IDictionary. It would allow the converter to perform additional logic on the base.Option that was passed in:
public class MyConverter : PatternConverter
{
override protected void Convert(TextWriter writer, object state)
{
User user = GetUserByUserName(base.Option);
string address = base.Properties["Address"] as string;
if (address != null && address.Length > 0)
{
if (user != null)
{
switch (address)
{
case "HomeAddress": writer.Write(user.HomeAddress); break;
case "WorkAddress": writer.Write(user.WorkdAddress); break;
}
}
else
{
// ???
}
}
else
{
// default display
writer.Write(user.HomeAddress); break;
}
}
}
|
|
Description
|
It would be useful if the user was able to supply additional properties to the <convert> tag in the form of:
<property name="foo" value="bar" />
<property name="Hello" value="World" />
The code below uses a <property> node to determine if the HomeAddress or the WorkAddress will appear in the log message. If the parameter is not present, the converter prints a default value.
<converter>
<name value="user-converter" />
<type value="Company.Project.Logging.UserConverter, Company.Project" />
<property name="Address" value="HomeAddress" />
</converter>
<conversionPattern value="%p %d %user-converter{Nicko} - %m%n" />
The <property> tags would be accessible via a Properties IDictionary. It would allow the converter to perform additional logic on the base.Option that was passed in:
public class MyConverter : PatternConverter
{
override protected void Convert(TextWriter writer, object state)
{
User user = GetUserByUserName(base.Option);
string address = base.Properties["Address"] as string;
if (address != null && address.Length > 0)
{
if (user != null)
{
switch (address)
{
case "HomeAddress": writer.Write(user.HomeAddress); break;
case "WorkAddress": writer.Write(user.WorkdAddress); break;
}
}
else
{
// ???
}
}
else
{
// default display
writer.Write(user.HomeAddress); break;
}
}
} |
Show » |
| No work has yet been logged on this issue.
|
|