Refactored branding of the application logs.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2022-11-09 00:41:26 +00:00 committed by Konstantina Chremmou
parent 6dd175eab0
commit fa04fda84a
5 changed files with 22 additions and 8 deletions

View File

@ -119,6 +119,16 @@ namespace XenAdmin
LogApplicationStats();
}, null, new TimeSpan(24, 0, 0), new TimeSpan(24, 0, 0));
var logFolder = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
BrandManager.CompanyNameShort,
BrandManager.BrandConsoleNoSpace,
"logs");
log4net.GlobalContext.Properties["LOG_FILE"] = Path.Combine(logFolder, $"{BrandManager.BrandConsoleNoSpace}.log");
log4net.GlobalContext.Properties["AUDIT_TRAIL"] = Path.Combine(logFolder, $"{BrandManager.BrandConsoleNoSpace}-AuditTrail.log");
log4net.GlobalContext.Properties["NETWORK_TRACE"] = Path.Combine(logFolder, $"{BrandManager.BrandConsoleNoSpace}-NetworkTrace.log");
log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(Assembly.GetCallingAssembly().Location + ".config"));
log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

View File

@ -237,7 +237,7 @@
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="${APPDATA}/[Citrix]/[XenCenter_No_Space]/logs/[XenCenter_No_Space].log"/>
<file type="log4net.Util.PatternString" value="%property{LOG_FILE}"/>
<encoding value="utf-8" />
<appendToFile value="true"/>
<maxSizeRollBackups value="5"/>
@ -249,7 +249,7 @@
</layout>
</appender>
<appender name="NetworkTraceAppender" type="log4net.Appender.RollingFileAppender">
<file value="${APPDATA}/[Citrix]/[XenCenter_No_Space]/logs/[XenCenter_No_Space]-NetworkTrace.log"/>
<file type="log4net.Util.PatternString" value="%property{NETWORK_TRACE}"/>
<encoding value="utf-8" />
<appendToFile value="true"/>
<maxSizeRollBackups value="5"/>
@ -276,7 +276,7 @@
<!-- Audit Trailing: The Audit logger will log all operations starting and finishing at INFO,
and all failed operations at WARN. -->
<appender name="AuditAppender" type="log4net.Appender.RollingFileAppender">
<file value="${APPDATA}/[Citrix]/[XenCenter_No_Space]/logs/[XenCenter_No_Space]-AuditTrail.log"/>
<file type="log4net.Util.PatternString" value="%property{AUDIT_TRAIL}"/>
<encoding value="utf-8" />
<appendToFile value="true"/>
<maxSizeRollBackups value="5"/>

View File

@ -29,9 +29,11 @@
* SUCH DAMAGE.
*/
using System;
using System.ServiceProcess;
using System.Reflection;
using System.IO;
using XenAdmin.Core;
namespace XenServerHealthCheck
{
@ -42,7 +44,13 @@ namespace XenServerHealthCheck
/// </summary>
static void Main()
{
log4net.GlobalContext.Properties["HEALTHCHECK_LOG"] = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
BrandManager.CompanyNameShort,
"XenServerHealthCheck\\logs\\XenServerHealthCheck.log");
log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(Assembly.GetCallingAssembly().Location + ".config"));
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{

View File

@ -13,7 +13,7 @@
</appSettings>
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="${PROGRAMDATA}/[Citrix]/XenServerHealthCheck/logs/XenServerHealthCheck.log"/>
<file type="log4net.Util.PatternString" value="%property{HEALTHCHECK_LOG}"/>
<encoding value="utf-8" />
<appendToFile value="true"/>
<maxSizeRollBackups value="5"/>

View File

@ -62,7 +62,6 @@ do
version_csharp ${assemblyInfo} && rebranding_global ${assemblyInfo}
done
rebranding_global ${REPO}/XenAdmin/app.config
rebranding_global ${REPO}/XenAdmin/XenAdmin.csproj
#XenModel
@ -84,7 +83,4 @@ sed -b -i -e "s/@AUTOGEN_PRODUCT_GUID@/${PRODUCT_GUID}/g" \
rebranding_global ${REPO}/XenAdminTests/TestResources/ContextMenuBuilderTestResults.xml
rebranding_global ${REPO}/XenAdminTests/XenAdminTests.csproj
#XenServerHealthCheck
rebranding_global ${REPO}/XenServerHealthCheck/app.config
set +u