NLOG varialble fileName and archiveFIleName - nlog

I have a generic target with a fileName ${logger}.csv. Is it possible for archiveFileName to use this same ${logger} in the archiveFileName?

Yes, you can use any ${variable} as many times as you want.
...
archiveFileName="${logger}.{#####}.csv"
...
Take look at Archival options and Size/time-based file archival in the NLog documentation for more information

Related

How to export many rrd files to xml files

I have set of old rrd files, so I need to convert them to xml files and again to rrd files in a new server. In order to create xml files from whole directory, I have used following simple bash script.
#!/bin/bash
cd /varcacti/rra
for i in ./traffic_in*;
do
/usr/local/rrdtool/bin/rrdtool dump $i /home/newuser/rrd_dump_xml/$i.xml;
done
This provides a set of xml files but the extension is not what I required actually. This provides,
traffic_in_1111.rrd>>>traffic_in_1111.rrd.xml
But I need traffic_in_1111.rrd>>>traffic_in_1111.xml. can someone help me to modify my code?
You want
/home/newuser/rrd_dump_xml/"${i%.rrd}".xml
#..........................^^^^^^^^^^^
which removes the rrd extension from the end of the string.
You might want to be more specific with the files you're looping over:
for i in ./traffic_in*.rrd

Can we use regular expression to mention cucumber options feature files?

#CucumberOptions(features = {"src/test/resources/features/module*.feature"},
tags = "#E2e",)
mvn clean verify -Dcucumber.features=”module*.feature” -Dcucumber.filter.tags="#E2E"
Is there any way to use regex to identify feature files? It takes it up as file name.
I want moduleone,moduletwo,modulethree to get executed.
PS: I am aware about tags but my logic is in such a way that using feature regex will help me.
The short answer is no. You can not. You can only reference files or directories. Patterns are not supported.

Can you use characters such as ( and ) in Nlog target filename for ASP.NET Core

For example ...
C:_Logs\UAT (Testing)\DebugService_${shortdate}.log
... does not work and writes a file named UAT (Testing)
C:_Logs\UATTesting\DebugService_${shortdate}.log
... does work and writes a file named DebugService_Date.log to the correct path.
Yes, special characters are supported.
Also there is an unit test that tests the specials characters, see https://github.com/NLog/NLog/pull/2714

string replace over collection of files

I am writing an MsBuild script to process config files and do transforms. I am creating a collection of a .Dev.config files thusly:
<ItemGroup>
<DevConfigFiles Include="..\Source\**\*.Dev.config"/>
</ItemGroup>
This works fine. Doing a task against %(DevConfigFiles.Identity) gives me what I would expect. I'd like to take that collection, and create a corresponding collection of the same file names, but with ".Dev.config" replaced with ".config".
I can't figure out the MsBuild syntax to get this done. What is the best way to accomplish this?
NOTE: I would consider alternative techniques for getting the list of *.config files and the corresponding list of *.Dev.config files, but really I'd like to understand the MsBuild syntax for calling string functions over a collection. That is the part that is tripping me up.
ANOTHER NOTE: I can't use the %(Extension) metadata in this case because it doesn't remove the ".Dev" portion of the string. It considers that part of the filename.
Similar SO question where the OP wants to take a collection of files and copy them with the name being based on the original string.
MSBUild: Copy files with a name based on the original (following a pattern)

Can you set a property value within the log4net config?

I'm working on a C# application that will have quite a few log files. These log files will be created in the same file path, and this file path will be determined at configuration time.
Is there a way I could specify this log files basepath in a single location the log4net configuration e.g. in a property?
I'd, of course, be referencing this basepath in the file param of each logfile appender?
One option I've considered is setting this path in the app.config/web.config, which the application will transfer into a log4net global context property. However, that would mean making sure that all loggers are created AFTER this property is set.
Any comments on the preferred, or the fallback method are welcome.
cheers!
You can implement a log4net custom pattern converter to return the basepath for logfiles. This is explained here: https://stackoverflow.com/a/4389828/910348.
The difference for your scenario is that your converter can simply read the basepath from your app.config/web.config.
Cheers!

Resources