I have Used NLog for logging and its working on local but when i published it then its not creating the log file while requesting the API. i have also set the
Copy to output directory = Copy always
Here is NLog.config File
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log" >
<!-- optional, add some variabeles
https://github.com/nlog/NLog/wiki/Configuration-file#variables
-->
<variable name="myvar" value="myvalue"/>
<!--
See https://github.com/nlog/nlog/wiki/Configuration-file
for information on customizing logging rules and outputs.
-->
<targets>
<!--
add your targets here
See https://github.com/nlog/NLog/wiki/Targets for possible targets.
See https://github.com/nlog/NLog/wiki/Layout-Renderers for the possible layout renderers.
-->
<target xsi:type="File" name="DebugFile" fileName="${basedir}/logs/Debug_${shortdate}.log" layout="${longdate} ${threadid} ${uppercase:${level}} ${message}"/>
<target xsi:type="File" name="ErrorFile" fileName="${basedir}/logs/Error_${shortdate}.log" layout="${longdate} ${threadid} ${uppercase:${level}} ${message} ${newline} ${exception:format=tostring} ${newline}"/>
<!--
Writing events to the a file with the date in the filename.
<target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log"
layout="${longdate} ${uppercase:${level}} ${message}" />
-->
</targets>
<rules>
<!-- add your logging rules here -->
<!--
Write all events with minimal level of Debug (So Debug, Info, Warn, Error and Fatal, but not Trace) to "f"
<logger name="*" minlevel="Debug" writeTo="f" />
-->
<logger name="*" levels="Debug,Info,Warn" writeTo="DebugFile" />
<logger name="*" level="Error" writeTo="ErrorFile" />
</rules>
</nlog>
Please tell me where i am doing wrong.
Related
I am using IntellIJ and just created a JavaFX sample project. I have not done any changes to the code but I am getting this Error:
Error: JavaFX runtime components are missing, and are required to run this application
my project.iml:
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library name="javafx-fxml">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-fxml/16/javafx-fxml-16.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-fxml/16/javafx-fxml-16-win.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-controls/16/javafx-controls-16.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-controls/16/javafx-controls-16-win.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-graphics/16/javafx-graphics-16.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-graphics/16/javafx-graphics-16-win.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/16/javafx-base-16.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/16/javafx-base-16-win.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
Why doesn't the library in project.iml work?
You need to download JavaFX SDK and connect it to the project as a library. See the detailed guide in JetBrains official documentation
and pay attention to this section
And don't forget to define these libraries in VM options of a run configuration in use. See this
In some special cases, we need to re-create a new local profile for a user, and then re-import some files/folders/HKCU registry keys from his former profile.
The process we'd like to use :
- Full backup of old user profile (anything, files, registry)
- Delete the C:\Users\ folder and profile infos in registry
- Re-import some files and reg key (not all)
Some guys pointed out that Microsoft has a tool for this called USMT and i tried the following :
- Save the whole user profile using this XML config :
<?xml version="1.0" encoding="UTF-8"?>
<_locDefinition>
<_locDefault _loc="locNone"/>
<_locTag _loc="locData">displayName</_locTag>
</_locDefinition>
<!-- Profile files -->
<component type="Documents" context="User">
<displayName>Files Migration</displayName>
<role role="Data">
<rules>
<!-- Anything ... -->
<include>
<objectSet>
<pattern type="File">%CSIDL_PROFILE%\* [*]</pattern>
</objectSet>
</include>
<!-- ... Except -->
<unconditionalExclude>
<objectSet>
<!-- Reg files -->
<pattern type="File">%CSIDL_PROFILE%\ [NTUSER.*]</pattern>
<pattern type="File">%CSIDL_LOCAL_APPDATA%\Microsoft\Windows\ [UsrClass.dat]</pattern>
<!-- IE Cache -->
<pattern type="File">%CSIDL_INTERNET_CACHE%\* [*]</pattern>
<!-- Temp -->
<pattern type="File">%TEMP%\* [*]</pattern>
</objectSet>
</unconditionalExclude>
</rules>
</role>
</component>
<!-- Registry -->
<component type="System" context="User">
<displayName>Registry Migration</displayName>
<role role="Settings">
<rules>
<!-- Get all HCKU -->
<include>
<objectSet>
<pattern type="Registry">HKCU\* [*]</pattern>
</objectSet>
</include>
</rules>
</role>
</component>
CommandLine for saving using ScanState.exe :
/listfiles:"C:\Logs\saved.log" /i:"C:\ProgramData\RebuildProfil\Conf\UserFull.xml" /ui:*\myuser/ue:*\* /hardlink /nocompress /o /v:13
Seems to work fine so far...
After profile deletion, il use LoadState.exe with following XML :
<?xml version="1.0" encoding="UTF-8"?>
<_locDefinition>
<_locDefault _loc="locNone"/>
<_locTag _loc="locData">displayName</_locTag>
</_locDefinition>
<!-- This component migrates My Music files -->
<component type="Documents" context="User">
<displayName _locID="miguser.mymusic">My Music</displayName>
<paths>
<path type="File">%CSIDL_MYMUSIC%</path>
</paths>
<role role="Data">
<detects>
<detect>
<condition>MigXmlHelper.DoesObjectExist("File","%CSIDL_MYMUSIC%")</condition>
</detect>
</detects>
<rules>
<include filter='MigXmlHelper.IgnoreIrrelevantLinks()'>
<objectSet>
<pattern type="File">%CSIDL_MYMUSIC%\* [*]</pattern>
</objectSet>
</include>
<merge script="MigXmlHelper.DestinationPriority()">
<objectSet>
<pattern type="File">%CSIDL_MYMUSIC%\ [desktop.ini]</pattern>
</objectSet>
</merge>
</rules>
</role>
</component>
The commandline :
/i:"C:\ProgramData\RebuildProfil\Conf\MigUserProfile.xml" /ui:*\myuser /ue:*\* /hardlink /nocompress /v:13
And instead of just migrating "My Music" files, the full user profile gets recreated (all files, all registry keys), doesn't seems the infos from the XML are taken into account.
So i wonder :
1- if it is possible to specify different XML files to scanstate and loadstate
2- if it is possible to only migrate some part of what was saved in the migration store
Any advice ? Thanks !
NLog is not writing to the configured log file while debugging under VS 2010 SP1.
When I break at a line that should write to the log file:
logger.Error("My Log Message");
I can see all of the IsXyzEnabled (in particular IsErrorEnabled) are true, and logger.Factory.AllTargets[0].FileName is 'C:/MyValidPath/${shortdate}.log'.
The valid path is pre-created. I have not added any particular permissions to the path (I know that would be required under IIS... is it required under VS debugging and if so, which permissions?).
I have NLog configured (I think) to throw an Exception if anything goes wrong, and I do not receive an Exception after executing logger.Error().
NLog Config File:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<nlog throwExceptions="true" />
<targets>
<target xsi:type="File" name="f" fileName="C:/MyValidPath/${shortdate}.log"
layout="${longdate} ${uppercase:${level}} ${message}" />
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="f" />
</rules>
</nlog>
I am getting lots of velocity debug and INFO messages showing up in my Jetty console. I would like to turn off info and debug messages that velocity spits out.
Environment:
I have a velocity properties file.
I have a log4j.xml file
I have a classpath which may error on the side of having more classes than one would expect like LogKitLogger which comes from commons-logging so it may not matter since it is not Logkit. Logkit is mentioned in the Velocity Configuring_Logging page
This is a sample message
2011-04-03 13:00:14.627:/myproject:INFO: Velocity [debug] ResourceManager : found /com/somecompany/something/somefile_ok.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
It seems like the following below needs to happen in order to turn off velocity messages that we do not want to see now. We also want to make it easy to turn velocity messages back on when we need them:
hook up velocity with log4j
specify that we only want to see ERROR and above.
Things I read:
The Stackoverflow Spit Velocity Out To Console post looked promising. However, the more I looked at the log4j.xml and compared it with the jetty configuration, the more it seems like the messages I am seeing are coming through jetty.
I have also read the Velocity Configuring_Logging page
Before I do any more Yak Shaving on this, I wanted to make sure I am on track with the approach outlined above
By the way, we're using Spring 3.x
Thanks for any help you can offer on this. :)
As suggested, here is the log4j.xml with minor tweaks to names:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<!-- ===================================================================== -->
<!-- -->
<!-- Log4j Configuration -->
<!-- -->
<!-- ===================================================================== -->
<!-- $Id: log4j.xml,v 1.6 2011-04-07 16:39:50 consumergear Exp $ -->
<!--
| For more configuration infromation and examples see the Jakarta Log4j
| owebsite: http://jakarta.apache.org/log4j
DEVELOPMENT CONFIGURATION
-->
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<!-- ================================= -->
<!-- Preserve messages in a local file -->
<!-- ================================= -->
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
<param name="Threshold" value="WARN" />
<param name="file" value="G:/logs/somewebplatform/somewebapp-webapp_log4j.log" />
<param name="append" value="true" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ISO8601} %5p %c:%L - %m%n" />
</layout>
</appender>
<!-- ============================== -->
<!-- Append messages to the console -->
<!-- ============================== -->
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out" />
<param name="Threshold" value="FATAL" />
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}:%L] %m%n" />
</layout>
</appender>
<!-- Hide those pesky Hibernate logs. -->
<logger name="net.sf">
<level value="ERROR" />
</logger>
<!-- Hide those pesky apache commons logs. -->
<logger name="org.apache.commons">
<level value="ERROR" />
</logger>
<logger name="com.yesorganization">
<level value="WARN" />
<appender-ref ref="FILE" />
</logger>
<!-- ======================= -->
<!-- Setup the Root category -->
<!-- ======================= -->
<root>
<priority value="WARN" />
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</root>
</log4j:configuration>
the velocity properties with minor name tweaks
#
# specify two resource loaders to use
#
resource.loader = file, class
#
##
## for the loader we call 'file', set the FileResourceLoader as the
## class to use, turn off caching, and use 3 directories for templates
##
file.resource.loader.description = Velocity File Resource Loader
file.resource.loader.class = org.apache.velocity.runtime.resource.loader.FileResourceLoader
file.resource.loader.path = d:/projects/somewebapp-webapp/src
file.resource.loader.cache = false
file.resource.loader.modificationCheckInterval = 0
#C:/Projectsyaya/someorg/src/core/java
##
## for the loader we call 'class', use the ClasspathResourceLoader
##
class.resource.loader.description = Velocity Classpath Resource Loader
class.resource.loader.class = org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
#
#jar.resource.loader.path = jar:file:/myjarplace/myjar.jar
#jar.resource.loader.path = jar:file:/WEB-INF/lib/someorg-something-1.116.jar
What strikes me is that the message you show shows [debug] in the message and is logged in Log4J format as [INFO]
My guess is that velocity is using the baked in logkit and logging to standard out which is redirected by Jetty to the log4j infrastructure.
Here you can see how Jetty can be reconfigured for redirecting stdout.
I would check the config if this is the case.
Then you should replace the velocity jar with the velocity jar without dependencies (as per velocity logging instructions) and add all other dependencies EXCEPT logkit (and pray no other library needs logkit). It will then switch to using Log4J and can be configured using category org.apache.velocity
If Logkit cannot be avoided then velocity must be told to log directly to Log4j :
VelocityEngine ve = new VelocityEngine();
ve.setProperty( RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
"org.apache.velocity.runtime.log.Log4JLogChute" );
ve.init();
I've had similar runins like this, but with JBoss, not with Jetty.
Modifying Peter's answer for spring gave me a bean def that looked like
<bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
<property name="velocityProperties">
<value>
resource.loader=class
class.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
velocimacro.permissions.allow.inline.local.scope
runtime.log.logsystem.class=org.apache.velocity.runtime.log.Log4JLogChute
</value>
</property>
</bean>
This worked great for me.
I have a console app using log4net (via Castle Windsor). Everything logs fine to the console when I debug, but when I publish and run the app, nothing is logged.
I have my log4net configuration in a separate file (log4net.config).
I'm thinking it's not finding the config file, but that's just a guess.
I'm a web dev and haven't deployed many console apps. Am I missing something?
Do I need to manually copy the log4net.config file to the exe directory?
I'm on VS2010.
app.config:
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor"/>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" requirePermission="false"/>
</configSections>
<appSettings>
...
<add key="log4net.Internal.Debug" value="false"/>
</appSettings>
<startup>
<supportedRuntime version="v2.0.50727"/></startup>
<castle>
<components>
...
</components>
<facilities>
<facility id="loggingfacility" configfile="log4net.config" loggingapi="log4net" type="Castle.Facilities.Logging.LoggingFacility, Castle.Facilities.Logging"/>
</facilities>
</castle>
</configuration>
log4net.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<log4net>
<root>
<!-- Value of priority may be ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF -->
<priority value="ALL" />
<appender-ref ref="ConsoleAppender" />
</root>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%d: [%-5p] %m%n" />
</layout>
</appender>
<logger name="Castle">
<level value="INFO" />
</logger>
</log4net>
</configuration>
This is a wild guess, but have you marked "Build Action" of your log4net.config file as 'Content', and set it's property "Copy to Output directory" to "Copy always".
This way you don't have to copy file, and this file is considered as 'content' of the build output and will be included in your publish.