I'm new to NLog and I confused with layout and layout-renderers.
I saw following code\pages:
https://github.com/NLog/NLog/wiki/Configuration-API
Layout = #"${date:format=HH\:mm\:ss} ${level} ${message} ${exception}"
https://github.com/NLog/NLog/wiki/CsvLayout (xml)
https://github.com/NLog/NLog/wiki/Exception-Layout-Renderer (something like the first)
I understand first (format of log message), but what is second and third I don't understand.
Layouts are defining the layout of the rendered output, examples are a CSV, JSON, XML (NLog 4.6+) or plain layout (the default). There are currently 5 layouts in NLog (including the default): https://nlog-project.org/config/?tab=layouts
Layout renderers are rendering values, e.g. a message, an exception, the process id etc. Also called "template markers". The layout renders looking as ${something}. There are around 100 layout renderers in NLog, but there are also some 3rd party layout renderers. See https://nlog-project.org/config/?tab=layout-renderers
You can see a layout as a method to combine layout renderers. The default layout is a bit hidden, but other layouts should make it more clear. See the examples below.
Some examples:
Default layout
Layout = #"${date:format=HH\:mm\:ss} ${level} ${message} ${exception}"
This is the default layout with 4 layout renderers (date, level, message, exception)
JSON layout
A file target with a JsonLayout with the same 4 layout renderers:
<target name='jsonFile' type='File' fileName='log.json'>
<layout type='JsonLayout'>
<attribute name='time' layout='${longdate}' />
<attribute name='level' layout='${level:upperCase=true}'/>
<attribute name='message' layout='${message}' />
<attribute name='exception' layout='${exception}' />
</layout>
</target>
This will create file with e.g. { "time": "2016-10-30 13:30:55.0000", "level": "INFO", "message": "this is message", "exception": "test" }
The same for CSV, but then to create CSV files (or CSV to the database etc).
Exception layout renderer: ${exception}
(See also https://github.com/NLog/NLog/wiki/Exception-Layout-Renderer)
This is for rendering the exception, as exceptions are captured separate from the message in NLog. See also How to proper log exceptions
Related
I'am trying to programmatically change a widget title in Connections. I use the following REST end-point:
/communities/service/atom/community/widgets?communityUuid=xyz&widgetInstanceId=xyz
Using the following PUT:
<?xml version="1.0" encoding="UTF-8"?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:snx="http://www.ibm.com/xmlns/prod/sn">
<title type="text">Bestandjes</title>
<category scheme="http://www.ibm.com/xmlns/prod/sn/type" term="widget">
</category>
<snx:widgetDefId>Files</snx:widgetDefId>
<snx:widgetInstanceId>Wfa656aa9103e_41d2_a7fc_44e84d642aa4</snx:widgetInstanceId>
<snx:hidden>false</snx:hidden>
<snx:location>col2</snx:location>
</entry>
With the WidgetInstanceId and communityID as a parameter. After the PUT is being executed, no error did occur but the title stays the same. Any suggestions?
You should be able to get this working by adding the following:
<snx:customTitle>TestChangeBookmarks</snx:customTitle>
i.e.
<?xml version="1.0" encoding="UTF-8"?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:snx="http://www.ibm.com/xmlns/prod/sn">
<title type="text">Bookmarks</title>
<category scheme="http://www.ibm.com/xmlns/prod/sn/type" term="widget">
</category>
<snx:customTitle>TestChangeBookmarks</snx:customTitle>
<snx:widgetInstanceId>W127627423458_49a0_bba1_af9bbf24d395</snx:widgetInstanceId>
<snx:hidden>false</snx:hidden>
<snx:location>col2</snx:location>
</entry>
*Note the element should contain the current title of the widget before making changes.
*Note is ignored for PUT request, therefore it is not needed.
More information on the widget entry elements can be found here:
https://www-10.lotus.com/ldd/lcwiki.nsf/xpAPIViewer.xsp?lookupName=IBM+Connections+5.0+API+Documentation#action=openDocument&res_title=Working_with_community_widgets_ic50&content=apicontent
Updated Community Widget Title
I am on NLog 4.3.5.
I have a long, complicated layout string that I want to save in a <variable /> for use in four layout attributes. Unfortunately, if I refer to the variable using
layout="${layout_full}"
then NLog complains that it cannot find that layout formatter (even though it isn't a layout formatter, it's a variable); and if I refer to the variable using
layout="${var:layout_full}"
then the layout evaluates to a blank string.
In other words, this:
<variable name="layout-full" value="
${longdate} [${level}] ${logger} ${all-event-properties}${newline}
${message}
${when:when='${exception}'!='':inner=
${newline}${exception}
${newline}${stacktrace}}
" />
<target name="stdout" xsi:type="Console" error="false" layout="a${var:layout-full}b" />
shows all log entries as "ab".
I have also tried putting all four targets into a SplitGroup and applying a layout to the group, but that's apparently unsupported.
Not sure if this is the case here, but the <variable> should be outside the <target> and <targets>
I added new configuration settings to my Liferay theme inside the file liferay-look-and-feel.xml
<setting configurable="true" key="show-navigation" type="checkbox" value="true" />
In the control panel I can see the setting with show-navigation label.
I want to translate it to Show the Main Navigation using Language.properties inside the theme.
Then to accomplish this in my theme I added this files (theme\docroot\WEB-INF\src\content):
Language.properties
Language_en.properties
Language_fr.properties
Which each file contains the translation as so:
show-navigation=Show the Main Navigation
then in theme\docroot\WEB-INF\ I added liferay-hook.xml
<?xml version="1.0"?>
<!DOCTYPE hook PUBLIC "-//Liferay//DTD Hook 6.2.0//EN" "http://www.liferay.com/dtd/liferay-hook_6_2_0.dtd">
<hook>
<portal-properties>portal.properties</portal-properties>
<language-properties>content/Language*.properties</language-properties>
</hook>
But it doesn't work. If I perform the same procedure for a portlet it works.
Why?
It's the name: You don't use content/Language*.properties, but just content/Language.properties. Otherwise I believe you're on the correct way to solve the problem, it's just this little detail
I have two (related) questions:
I am having a puzzling problem with the Advanced Find function. I set up the fields I require, both in the criteria and display section and then hit 'Download Fetchxml'. What I end up with is fields that I never asked for. For example, in my advanced find I asked for All Activities. I changed the results to show me only the Date Created, Activity Type, Subject and Regarding fields. The (truncated) generated fetchXML looks like this:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="activitypointer">
<attribute name="activitytypecode" />
<attribute name="subject" />
<attribute name="activityid" />
<attribute name="instancetypecode" />
<attribute name="community" />
<attribute name="createdon" />
<attribute name="regardingobjectid" />
<order attribute="subject" descending="false" />
Why have those extra columns been included? I didn't ask for the 'community' attribute anywhere, for example.
Second question:
What determines the output order of the fields? I ran the above fetchXML through Fetch Tester 3000 (saved my life - thank you!) and the output table bears no relation to the order of the attributes in the xml. This is true also when I use the fetchXML elsewhere.
Thanks in advance for your comments
The FetchXML returned by the button Download Fetch XML is generated internally and in some scenarios it returns extra columns (as you found), for example the primary key field of the entity is always added.
If you remove the additional attributes the FetchXML is still valid and can be executed.
Regarding the order, the tool you used (Fetch Tester 3000) display the fields inside the Table View ordered by their logicalname, inside Dynamics CRM the order of the attributes (subgrids and advanced find results) is defined using another XML definition known as LayoutXML
In Sharepoint 2007, I have created a layout. As you know when the user creates a page he chooses a layout from a listbox.
When you select a different element in the listbox, there is a preview image that changes on the left.
I thought this was controlled by the node PublishingPreviewImage in the xml of the layout. I have verified that the image exists in that place.
It is not working.
The code I use is:
<File Path="TituloTextoCtrl.aspx" Url="TituloTextoCtrl.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists ="TRUE">
<Property Name="PublishingPreviewImage" Value="~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/titulotextoctrl.png, ~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/titulotextoctrl.png" />
<Property Name="MasterPageDescription" Value="Plantilla Titulo+Texto+Control" />
<Property Name="ContentType" Value="Titulo+Texto+Control" />
<Property Name="PublishingAssociatedContentType" Value=";#Vialibre_ContentTypeGeneral;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF39005215cca003b74e479baa123eb1dc5702;#" />
</File>
You also need XML to provision the image:
<Module Name="MyPreviewImages" Url="_catalogs/masterpage" IncludeFolders="??-??" Path="" RootWebOnly="TRUE">
<File Url="titulotextoctrl.png" Name="Preview Images/titulotextoctrl.png" Type="GhostableInLibrary">
</File>
</Module>
first of all upload yor layout page image in site collection document library or picture libary. Then Go to site actions--> site settings-->Galleries-->master pages and pagelayouts-->. In pagelayouts you can see your new layoutpage.
choose edit properties of your layoutpage there you can see the properties of that layout page. There is one column called preview image, give the url of image there that you already uploaed in the docu libary. click on Ok, now you have got preview image of your layout page.
Thx to Rich Bennema and Hojo for answering, there are right, but at the same time, my problem is that this layouts were deployed, and when I deploy again changing the PublishingPreviewImage, the layout is not updating. So my problem was a problem of controlling events so that everytime that I deploy the layouts are recreated in case there is changes.
This I know because it has worked for new layouts.
So for those who try this. Use the code I have provided with the one of Rich Bennema to upload the image.