can you use a variable in the message logging policy for host and port? - api

can you use a variable in the message logging policy for host and port? for example
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<MessageLogging async="false" continueOnError="false" enabled="true" name="splunk">
<Syslog>
<Message>Message. id = {request.header.id}</Message>
<Host>{variable}</Host>
<Port>{variable}</Port>
</Syslog>
</MessageLogging>

At this time, the Host and Port entries cannot be variables.

An alternative to using variables at runtime is to set those attributes at build time using a build tool like maven.

Related

What is the expected contents of Web.config if appSettings entry is parameterized?

I'm trying to parameterize an appSettings entry in my Web.config. Since this is a part of a quite long build process, I'd like to verify that my parameterization actually works before trying it out on our CI server (i.e. trial and error is not a good idea).
So, if I run MSBuild with /T:Package to create my package, I expect that the .zip file created would contain a Web.config with my appSetting entry tokenized, just like a connection string is tokenized.
But, so far I do not get my expected result. Is my assumption wrong?
Is it maybe that the tokenization/replacing happens first in the actually deploy-step?
Here's the tokenized web.config. Notice how my appSetting isn't tokenized:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<lots of stuff here...>
<connectionStrings>
<add name="DefaultConnection" connectionString="$(ReplacableToken_DefaultConnection-Web.config Connection String_0)" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="mySetting" value="monkey"/> <!-- Shouldn't monkey this be tokenized? -->
</appSettings>
<rest of web config here ...>
The con string tokenization is taken care of in the web publishing MSBuild targets. It's not a part of Web Deploy itself. In your scenario I'd expect that the package was created and app settings are not modified.
When the package is created there are two ways you can see the parameters:
Use msdeploy.exe and pass GetParamters - http://technet.microsoft.com/en-us/library/dd569044(v=ws.10).aspx
You can crack open the .zip file and look at the parameters file inside of it

appsetting not working in wcfservice web.config file

Detailed Error Information:
Module IIS Web Core
Config Error The configuration section appSetting cannot be read because it is missing a section declaration
my web.config file below:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSetting>
<add key="myserver" value="localhost:12345,localhost:12346"/>
</appSetting>
</configuration>
Try using appSettings instead.

Have multiple alias for Webapp

I have deployed a application in Apache tomcat. Suppose name of project is abc (or deployed from abc.war).
I access it using url :=> http://localhost:8080/abc/
But I want to redirect or have aliases for web app. like
http://localhost:8080/abc/
http://localhost:8080/abc1/
http://localhost:8080/abc2/
http://localhost:8080/abc3/
All the above reference to same Web-app. How can I do it and I do not want to copy paste the folder as many times and renaming it.
~Thanks
The best solution is not using a warfile.
Copy all the content into a specified directory (i.e. \user\abc) and then you can either configure all the contexts in two ways.
one xml for every context to map, by putting it into your: %CATALINA_HOME%\conf\Catalina\localhost. Keep in mind that the name of the xml file will be the mapping of your webapp, but you can redefine it with the path attribute inside the xml. In your case you have to produce abc.xml, abc1.xml, abc2.xml and their content should be something like:
abc.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="\user\abc" path="abc" reloadable="false"/>
abc1.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="\user\abc" path="abc1" reloadable="false"/>
you can edit directly the %CATALINA_HOME%\conf\server.xml by inserting, inside the <Host ...> tag, the contexts definitions, something like this:
<Host ...>
<Context docBase="\user\abc" path="abc" reloadable="false"/>
<Context docBase="\user\abc" path="abc1" reloadable="false"/>
</Host>
If you need to provide database datasource information to a context, just add the tag Resource to the context definition itself (either in an xml file or in server.xml),here you go with a sample:
<Context docBase="\user\abc" path="abc" reloadable="false">
<Resource auth="Container" description="DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
maxActive="4"
maxIdle="2"
maxWait="5000"
name="jdbc/myJNDIname"
password="mypass"
type="javax.sql.DataSource"
url="jdbc:oracle:thin:#host:port:SID"
username="myuser"/>
</Context>
If you need this last part, just use it, obviously, for every context you like to duplicate.
Hope it helps.
the easiest way is create soft link directory of the app, like this
ln -s $PWD/abc $PWD/abc1
ln -s $PWD/abc $PWD/abc2
ln -s $PWD/abc $PWD/abc3

(407) Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. )

I am getting an error when my application tries to communicate with a web service
(407) Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. )
I saw a few topics but I could not understand. I am using VB.net
As the error says, your proxy server is preventing access to the service. You can either write some code to ask the user for credentials for the proxy, or (easier) you can put the following in your applications app.config:
<system.net>
<defaultProxy useDefaultCredentials="true"/>
<system.net>
There are other settings if you have more complex requirements. Try here for guidance
http://msdn.microsoft.com/en-us/library/09361bca
Your app.config file should look like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.net>
<defaultProxy useDefaultCredentials="true" />
</system.net>
</configuration>
I think the error referring to TraceUtility is unrelated - different problem.

NLog in WCF Service

Can I use NLog in a WCF Service? I am trying to but cannot get it to work.
First I set up a simple configuration in a Windows Forms application to check that I was setting up correctly and this wrote the log file fine (I am writing to a network location using name and not IP address).
I then did exactly the same thing in the WCF Service. It did not work.
To check permissions I then added some code to use a TextWriter.
TextWriter tw = new StreamWriter(fileName);
tw.WriteLine(DateTime.Now);
tw.Close();
This worked OK so I know I can write to the location.
Check that your NLog.config file is in the same directory as your .svc file and NOT the Bin directory.
If you've just added the config file to the WCF project, then published it you will probably find your config file has been copied to the bin directory which is why NLog can't find it. Move it to up a level then restart the website hosting the service (to make sure the change is picked up).
This had me stumped for a while this morning!
Put your NLog config in the web.config file. Like so:
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
</configSections>
. . . (lots of web stuff)
<nlog>
<targets>
<target name="file" xsi:type="File" fileName="${basedir}/logs/nlog.log"/>
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="file" />
</rules>
</nlog>
</configuration>
See my comment to your original question for how to turn on NLog's internal logging.
To turn on NLog's internal logging, modify the top of you NLog config to look like this:
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.mono2.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="Trace"
internalLogFile="nlog_log.log"
>
The key parts are internalLogLevel and internalLogFile.
You can also set internalLogToConsole to true or false to direct the internal logging to the console.
There is another setting, throwExceptions, that tells NLog whether or not to throw exceptions. Ordinarily, this is set to false once logging is successfully configured and working. You can set it to true to help determine if your problem is due to an NLog error.
So, if you had all of those options enabled, the top of your NLog configuration might look like this:
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.mono2.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="Trace"
internalLogFile="nlog_log.log"
internalLogToConsole="true"
throwExceptions="true"
>
My first guess is that NLog is not finding the config information. Are you using an external config file (NLog.config) or "inline" configuration (in your app.config or web.config)? In your project, is(are) your config file(s) marked (in Properties) as Copy Always?