Log4net hourly rollover but with datePattern of seconds - log4net

I'm trying to write a log which creates new file every hour, which can be done simply using the datePattern set to but I need the datePattern (or at least the filename to consist of yyyyMMddHHmmss but still, rollover every 1 hour.
Obviously when I set it gives the result but the rollover is every second.
I've search all over but couldn't find any answer.
Thanks for the assistance.

Log4net does not support this. You could copy the source code of the rolling file appender and implement this feature for yourself. As far as I can tell you cannot derive from the class and override the behavior since the date pattern is used in private methods.

Related

Log statement is repeating in log files

I have to log in different-2 file. So I have created two appender. One for basic log which would log little bit information.
Second appender will be dynamic and depending on the one parameter log file name will be different. Both scenario are working fine.
Now just found the log statement are getting added.
Means first time it write once, second time tow lines and third time three and so on.. My program runs on every 20 seconds. If I close the program and run again it will not repeat but if continuous runs every 20 second then it start repeat log.
I have used log4j.Create to logger and adding appender in this. Every thing I am doing by code. Not using any log file. Below is one of them.
static Logger loggerCustom = Logger.getLogger("CustomLog");
PatternLayout plt = new PatternLayout();
plt.setConversionPattern("%-7p %d [%t] %c %x - %m%n");
fh = new FileAppender(plt, "logs\\" + strDate + "\\CustomLog.log");
loggerCustom.addAppender(fh);
loggerCustom.setAdditivity(false);
Dear All above issue has been resolve by adding below line before appending appender.
.removeAllAppenders()

logstash refresh lookup file when using translate function

I have the yml file which I used the "traslate" function to do lookup.
What was done is to translate a string like "superhost.com" to "found".
My problem is that if I were to add in more entries there entries will not be reflected.
For example
I add a "ultrahost.com" entry into the yml file while logstash is still running. Incoming logs with "ultrahost.com" will not be translated to "found". This will only work after I have restarted the logstash script.
There is a refresh_interval parameter to the translate plugin that can be used to specify how often to re-read the file. The default is 300 seconds (5 minutes). You can lower that to be whatever interval you think will satisfy how often that the file will be updated.

icCube - How can I modify the information that will be exported in Excel file

This the OutPut of my Excel file :
I want to Change the date to be more comprehensible. Thanks for your Help
This is known issue, will be part of next release.
As a workaround you can use DateToString function in your measure.
DateToString function does not convert currently, will be done in the next release, measures to their values (see issues).
As a workaround you'll have to do this manually :
[Measures].[My Date].value
or
[Measures].[My Date].value->asValue()
The second is needed if you're using a special aggregation method (e.g. min/max/open/close ) and will need Java to be active in icCube (doc)

Is it possible to use the ${shortdate} in the internalLogFile?

Is it possible to use the ${shortdate} in the internalLogFile?
<nlog internalLogFile="C:\Logs\${shortdate}_nlog.log"
<targets>
<target name="logfile"
fileName="C:/logs/${shortdate}_dev.log"
</target>
I'm getting the expected dated logfile, but the internal log file is named ...
${shortdate}_nlog.log
Short answer: No.
Longer answer: The internal logger file name is just a string. It's read in during initialization and the XmlLoggingConfiguration class ensures that the directory exists whereas (for example) the FileTarget uses a Layout for fileName that converts the value provided using LayoutRenderers.
https://github.com/NLog/NLog/issues/581#issuecomment-74923718
My understanding from reading their comments is that the internal logging should be simple, stable, and used sparingly. Typically you are only supposed to turn it on when trying to figure out whats going wrong with your setup.
You can still dynamically name your internal log file based on the date time if you want. However it won't have the same rollover effect a target file would. It would essentially have a different datetime whenever you initialized your logger I think.
DateTime dt = DateTime.Now;
NLog.Common.InternalLogger.LogFile = #"C:\CustomLogs\NLog_Internal\internal_NLogs" + dt.ToString("yyyy-MM-dd") + ".txt";

Groovy Script set timezone for timestamp

I've been struggling to set the Time zone inside a GroovyScript. By now I have found out that the following code returns the actual time stamp from my location.
javax.xml.datatype.DatatypeFactory.newInstance()
.newXMLGregorianCalendar( GregorianCalendar.getInstance() ).toString()[0..21] + "Z"
Now I need it to return the date and time in UTC specifically, so it has the main server's timezone and could be run from any other location.
All these are run in a GroovyScript test step in SoapUi and it will be used as a variable inside a WSDL request.
Note: This will be used as a single liner in the Custom Properties of a Soap Project.
One of the solution:
System.setProperty('user.timezone', 'UTC')
def gc= new GregorianCalendar()
the second is:
c = Calendar.instance
c.timeZone = TimeZone.getTimeZone("UTC")
The first solution work with a GregorianCalanedar which easy to convert to xml date. But I think best solution work with Calendar.
I don't test these codes! Please check it!

Resources