Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0008847opensim[GRID] Other Servicepublic2021-01-04 20:562021-01-10 03:48
ReporterFerd Frederix 
Assigned To 
StatusresolvedResolutionnot fixable 
PlatformOperating SystemOperating System Version
Product Version 
Target VersionFixed in Version 
Summary0008847: Log4Net no longer uses environment variables
DescriptionFrom the wiki at [^]

Logging for multiple instances run from a single OpenSim.exe isn't something that the default log4net configuration handles. Fortunately, log4net accepts environment variables. This allows a script wrapping OpenSim.exe to specify a log location by setting an environment variable.

I've used this very nice feature for almost 4 years so I don't thing I'm doing something wrong all since I released a new versions of Opensim from October.

DreamGrid is a GUI that sets up and runs stock, core Opensim. DG places a SYSTEM environment variable such as OSIM_LOGPATH = "c:/tmp", and uses log4net's macro in the opensim.exe.config to relocate the log file such as <file value="${OSIM_LOGPATH}\OpenSim.log" />. I use it there and also to change Log levels.

Log4Net complains at the very start that no log level is set if I replace the log level with OS_LOGLEVEL=INFO.

Hidden traps: There can be no space after the "OS_LOGLEVEL=" in Windows, and this must be a System level env var. I set this in code based on GUI settings and then launch the opensim processes. With an environment variable I can boot 100+ regions in under 30 seconds on decent hardware as it is set per Instance and can be changed rapidly. Without it, I must add long delays to ensure operation is correct.

It stopped working for me several months ago at the rev listed, and has caused endless issues as there is no decent replacement other than what is essentially sed/grep, which in turn means single-threaded operation as there is only one exe and one config in my builds. I must launch and wait for OpenSimulator to boot before starting a new region or the logs get mixed up, or worse, OpenSimulator fails to load a logger at all, because the .config file is being written when booting another instance which requires moving the log files each time.

The specs also appear to have changed in Log4Net, perhaps in later versions than ours. What worked before was per the Opensimulator Wiki:

<level value="${OS_LOGLEVEL}"/>

Log4Net and various web sites recommend a different syntax: <level value="%{OS_LOGLEVEL}"/> as well as adding a pattern layout. <file type="log4net.Layout.PatternLayout" ... to it, as in <level type="log4net.Util.PatternString" value="%env{OS_LOGLEVEL}"/>. But this makes no difference.

One more question. The StatsLogFileAppender logger creates a file in the proper place, but never writes to it, even with various hourly stats being written to the console. Has anyone made this work or know the trick?
Steps To ReproduceChange opensim.exe.config so the Log level is a environment variable:

<level value="${OS_LOGLEVEL}"/>
<level type="log4net.Util.PatternString" value="%env{OS_LOGLEVEL}"/>

Add the desired log level variable to the System Properties, which Microsoft has handily removed from the control panel and hidden away. On Win10, right click 'This PC', select "Properties", scroll down almost to the bottom under 'Related Settings', select 'Advanced System Settings'. In the Advanced tab select Environment Variables, and add a OS_LOGLEVELwith a value of INFO to the BOTTOM (system) section.

Run Opensim.exe and you get an error:

OpenSim.exe -inidirectory="Regions/Welcome"

log4net:ERROR Undefined level [${OS_LOGLEVEL}] on Logger [OpenSim.ApplicationPlugins.RegionModulesController.RegionModulesControllerPlugin].
22:19:38 - [OPENSIM MAIN]: configured log4net using default OpenSim.exe.config

Same for %env{OS_LOGLEVEL}

OpenSim.exe -inidirectory="Regions/Welcome"
log4net:ERROR Undefined level [%env{OS_LOGLEVEL}] on Logger [OpenSim.ApplicationPlugins.RegionModulesController.RegionModulesControllerPlugin].

also errors for the recommended version:

<level type="log4net.Util.PatternString" value="%env{OS_LOGLEVEL}"/>

Additional Information.config with OS_LOGLEVEL changed

<?xml version="1.0" encoding="utf-8" ?>
<configuration >
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
    <loadFromRemoteSources enabled="true" />
    <!--<add key="log4net.Internal.Debug" value="true"/>-->
    <appender name="Console" type="OpenSim.Framework.Console.OpenSimAppender, OpenSim.Framework.Console">
      <filter type="log4net.Filter.LoggerMatchFilter">
        <loggerToMatch value="special"/>
        <acceptOnMatch value="false"/>
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date{HH:mm:ss} - %message" />
        <!-- console log with milliseconds. Useful for debugging -->
<!-- <conversionPattern value="%date{HH:mm:ss.fff} - %message" /> -->

<!-- If you want automatic log-rolling then use RollingFileAppender instead of FileAppender:
    <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
      <file value="log/OpenSim.log" />
      <rollingStyle value="Date" />
      <datePattern value="'.'yyyy-MM-dd"/>

    <appender name="LogFileAppender" type="log4net.Appender.FileAppender">
      <file type="log4net.Util.PatternString" value="OpenSim.log" />
      <appendToFile value="true" />
      <filter type="log4net.Filter.LoggerMatchFilter">
        <loggerToMatch value="special"/>
        <acceptOnMatch value="false"/>
      <layout type="log4net.Layout.PatternLayout">
        <!-- <conversionPattern value="%date %-5level (%thread) - %logger %message%newline" /> -->
        <conversionPattern value="%date %-5level %message%newline" />

    <appender name="StatsLogFileAppender" type="log4net.Appender.FileAppender">
      <file type="log4net.Util.PatternString" value="OpenSimStats.log"/>
      <appendToFile value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date - %message%newline" />

      <level type="log4net.Util.PatternString" value="INFO" />
      <appender-ref ref="Console" />
      <appender-ref ref="LogFileAppender" />

    <!-- Independently control logging level for per region module loading -->
    <logger name="OpenSim.ApplicationPlugins.RegionModulesController.RegionModulesControllerPlugin">
      <level type="log4net.Util.PatternString" value="%env{OS_LOGLEVEL}"/>

    <!-- used for stats recording -->
    <logger name="special.StatsLogger">
      <appender-ref ref="StatsLogFileAppender"/>

TagsNo tags attached.
Git Revision or version numberVersion #ba46b5bf8bd0 libomv master 2020-09-21 2020-10-14 19:44
Run Mode Grid (1 Region per Sim)
Physics EngineBulletSim
Script EngineXEngine
Environment.NET / Windows64
Mono VersionNone
Attached Files

- Relationships

-  Notes
UbitUmarov (administrator)
2021-01-05 01:50

see no changes on that commit related to log4net
possible something changed elsewhere
UbitUmarov (administrator)
2021-01-05 05:57

apparently from googling and from source, Level must be simple string, not log4net.Util.PatternString
UbitUmarov (administrator)
2021-01-05 06:20

was able to change the log filename with
<file type="log4net.Util.PatternString" value="%env{OSIM_LOGPATH}"/>

<file value="${AName}"...
did nothing

log4Net current version is 2.0.8
tried to update to 2.0.12 but it failed to compile
UbitUmarov (administrator)
2021-01-05 06:21
edited on: 2021-01-05 06:24

btw can not find the wiki entry you mention
nm. you had a extra ':' on the url

UbitUmarov (administrator)
2021-01-05 06:52

ok, to actually change path it needs to be
<file type="log4net.Util.PatternString" value="%env{OSIM_LOGPATH}\OpenSim.log" />
UbitUmarov (administrator)
2021-01-05 07:24
edited on: 2021-01-05 11:25

well now <file value="${OSIM_LOGPATH}\OpenSim.log" /> did work
guess i had issues with setting environment and vs debug

JeffKelley (reporter)
2021-01-06 13:50

Using a3b2625 of 2021-01-06

   <appender name="LogFileAppender" type="log4net.Appender.FileAppender">
      <file value="../log/OpenSim_${SIMULATOR}.log" />
and my logs are stored in ../log/OpenSim_1.log etc as usual.
Ferd Frederix (reporter)
2021-01-08 12:03

Are any of you on Windows? I am on 10.0.19042 20H2

I have since compiled Dev master and with zero success on any environment vars being seen.
UbitUmarov (administrator)
2021-01-08 12:28

win 10 19042.685
note that im changing opensim.exe.config
Ferd Frederix (reporter)
2021-01-09 20:13

Not fixable as Log level is needed but can't be fixed.
UbitUmarov (administrator)
2021-01-10 03:48

yes, as i said log level does not expand environment.. it wants one of its defined strings. And that is on log4 code, now ours

- Issue History
Date Modified Username Field Change
2021-01-04 20:56 Ferd Frederix New Issue
2021-01-04 20:57 Ferd Frederix Summary Log4Net no longer not use environment variables => Log4Net no longer uses environment variables
2021-01-04 20:57 Ferd Frederix Steps to Reproduce Updated View Revisions
2021-01-04 20:57 Ferd Frederix Additional Information Updated View Revisions
2021-01-05 01:50 UbitUmarov Note Added: 0037460
2021-01-05 05:57 UbitUmarov Note Added: 0037461
2021-01-05 06:20 UbitUmarov Note Added: 0037462
2021-01-05 06:21 UbitUmarov Note Added: 0037463
2021-01-05 06:24 UbitUmarov Description Updated View Revisions
2021-01-05 06:24 UbitUmarov Note Edited: 0037463 View Revisions
2021-01-05 06:52 UbitUmarov Note Added: 0037464
2021-01-05 07:24 UbitUmarov Note Added: 0037465
2021-01-05 11:25 UbitUmarov Note Edited: 0037465 View Revisions
2021-01-06 13:50 JeffKelley Note Added: 0037473
2021-01-08 12:03 Ferd Frederix Note Added: 0037476
2021-01-08 12:28 UbitUmarov Note Added: 0037477
2021-01-09 20:13 Ferd Frederix Note Added: 0037491
2021-01-09 20:13 Ferd Frederix Resolution open => not fixable
2021-01-09 20:14 Ferd Frederix Status new => resolved
2021-01-10 03:48 UbitUmarov Note Added: 0037495

Copyright © 2000 - 2012 MantisBT Group
Powered by Mantis Bugtracker