Log4j in Websphere - servlets

I recently take over a web application project using websphere and log4j running under AIX. To create a development environment, I setup all the components in windows, using eclipse to compile a WAR file and deploy it.
All is working fine except that log file is not created.
I changed the log file in log4j.properties from something like in below and and give everyone full access permission to the directory:
log4j.appender.F1.File=/abc/def/logs/admin.log
to
log4j.appender.F1.File=c:/logs/admin.log
What else can I check?
I create a simple standalone testapp which use the same log4j.properties and it can create the log file, but when the servlet deployed to websphere, it doesn't work. Please help! Thanks!

Ok, I think this article should help you. It seems that WebSphere CE uses log4j by default and controls it with a global properties file. There is a section on how to use application-specific properties files.

Here is what I try and do to troubleshoot similar issues.
Turn on log4j debugging to see where it actually picks up the file from. You need evidence of which file is picked up (so turning the debug on is a worthwhile activity) This provides you information with what log4j is trying to do to locate the configuration file.
-Dlog4j.debug=true
I would not hardcode the log4j location in the code. Instead I
would use the log4j.configuration System property and state that in
the JVM arguments. This way even I don't need to touch my code.
-Dlog4j.configuration=file:///home/manglu/log4j.properties
I would use this approach irrespective of the runtime server that I use (be it Tomcat or WAS CE or WAS)
Hope this helps

I suggest you use environment variables set on your server like this :
You must access the admin console of your server.
Under custom properties
Server_path=/abc/def/logs
In your log4j, use this : {$server_path}/log.txt
Make sure the user running the app has access to that directory.

Related

Getting the WebRole module inside my Azure web role app to read web.config settings

I understand that the WebRole module inside my Web Role web app project runs inside WAIISHost.exe and the rest of the app runs inside W3WP.EXE. Therefore web.config settings cannot be read from the WebRole app domain.
This can be solved by creating a special "waiishost.exe.config" in the web project file and set the "Copy to Output Directory" property to "Copy Always".
That's fine. However, now, I have config settings in ServiceConfiguration AND web.config AND "waiishost.exe.config". This is only a minor but annoying issue though. The biggest problem is that when I publish my Azure project, ServiceConfiguration and web.config get automatically transformed into the production values whereas waiishost.exe.config does not get transformed, so I end up with development config going into the production environment. (the production env is not live yet, so not a major issue yet)
Can anyone think of any ideas as to how I can also have the Publish process transform waiishost.exe.config? Maybe I could run some kind of startup process which could simply copy and rename the web.config file to be waiishost.exe.config before waiishost.exe starts.
BTW, I cannot simply move config to the ServiceConfiguration file as I have whole config sections and connection strings which are used by third party components, like the ServiceBusConfiguration section.
Many thanks
Yes, there is.
A little manual, but is "one-time-setup" per project. Check out this and that blog posts I've made a while ago (even before you could have ServiceConfiguration files). These blog posts will give you a great idea on how to achieve your desire.

Vs2010 Proxy, where's the code

I have inhherited a vs2010 c# web project (asp.net). It has a web reference to a web service. There's been a slight change to the service - a new operation has been added. I'd like to update the proxy class so that i can call the new operation but i can't find the class. I seem to remember there used to be a "show all files" button in solution explorer that would reveal the proxy class but i can see no sign of that. Unfortunately, i'm not able to refresh the proxy by pointing it at the web service metadata wsdl because vs is no longer installed on any pc that can reach the web service. Anyone know where i can find the proxy class?
It doesn't matter you can't find it in Visual Studio - you can always locate a proper file in your filesystem, under the project directory.
Problem was, the app was running - doh!
Yes, you are right. There is a "Show all files" icon in the tool bar. It will only be available when you have a project selected, so you want to select the web service's parent project:
Expand the service reference and under it the file called Reference.cs is the proxy class.
You should NOT be hand editing this though. You should make the changes to the service and then regenerate the proxy using the Update Service Reference right click option. But then if you really can't do that as you say, then just hand edit the file. But beware that any changes you make will be lost if someone does regenerate it again in the future. Very Risky! (I prey you are using source control)
There is a WSDL.exe command line tool.
Copy and execute this command line tool in the PC where you can have access to the WebService, it will generates the proxy again and you can replace them with the files in your project.
http://msdn.microsoft.com/en-us/library/7h3ystb6(v=vs.80).aspx

Problem with Team Build 2010 and web.config transformation

I'm struggling to get web.config transformations working with automated builds.
We have a reasonably large solution, containing one ASP.NET web application and eight class libraries. We have three developers working on the project and, up to now, each has "published" the solution to a local folder then used file copy to deploy to a test server. I'm trying to put an automated build/deploy solution in place using TFS 2010.
I created a build definition and added a call to msdeploy.exe in the build process template, to get the application deployed to the test server. So far, so good!
I then tried to implement web.config transforms and I just can't get them to work. If I build and publish locally on my PC, the "publish" folder has the correct, transformed web.config file.
Using team build, the transformation just does not happen, and I just have the base web.config file.
I tried adding a post-build step in the web application's project file, as others have suggested, similar to:
<target name="AfterBuild">
<TransformXml Source="Web.generic.config"
Transform="$(ProjectConfigTransformFileName)"
Destination="Web.Config" />
</target>
but this fails beacuse the source web.config file has an "applicationSettings" section. I get the error
Could not find schema information for the element 'applicationSettings'.
I've seen suggstions around adding arguments to the MSBuild task in the build definition like
/t:TransformWebConfig /p:Configuration=Debug
But this falls over when the class library projects are built, presumably because they don't have a web.config file.
Any ideas? Like others, I thought this would "just work", but apparently not. This is the last part I need to get working and it's driving me mad. I'm not an msbuild expert, so plain and simple please!
Thanks in advance.
Doug
I just went through this. Our build was a bit more complicated in that we have 8 class libraries and 9 web applications in one solution. But the flow is the same.
First off get rid of your after build target. You won't need that.
You need to use the MSDeployPublish service. This will require that it be installed and configured properly on the destination server. Check the following links for info on this part:
Note that the server in question MUST be configured properly with the correct user rights. The following sites helped me get that properly set up.
http://william.jerla.me/post/2010/03/20/Configuring-MSDeploy-in-IIS-7.aspx
http://vishaljoshi.blogspot.com/2010/11/team-build-web-deployment-web-deploy-vs.html
How can I get TFS2010 to run MSDEPLOY for me through MSBUILD?
The next part requires that your build definition have the correct MSBuild parameters set up to do the publish. Those parameters are entered in the Process > 3.Advanced > MS Build Arguments line of the build definition. Here's a hint:
(don't change the following for any reason)
/p:DeployOnBuild=True
/p:DeployTarget=MsDeployPublish
/p:CreatePackageOnPublish=False
/p:MSDeployPublishMethod=WMSVC
/p:SkipExtraFilesOnServer=True
/p:AllowUntrustedCertificate=True
(These control where it's going)
/p:MSDeployServiceUrl="https://testserver.domain:8172/msdeploy.axd"
/p:UserName=testserver\buildaccount
/p:Password=buildacctpassword
/p:DeployIisAppPath="MyApp - TESTING"
Obviously the user will have to be configured in IIS on the target server to be allowed access to that axd (see previous links). And the IisAppPath is the name of the website on the target server.
You won't have to do anything special for the config transformations as the build itself will take care of that for you. Just have the correct setting in the line at Process > 1. Required > Items to Build > Configurations To Build.
Instead of trying to do the deploy by adding tasks myself into the build process template, I followed advice in Vishal Joshi's blog post here.
Now the entire project is built and deployed and the web.config transformations work also. Brilliant!
I now have another problem to solve! The web application references web services and the build process results in an XmlSerializers dll. However, although this is built OK, it does not get deployed to the web host. I think this needs a new post!
Doug

Web Deployment Project failed to map path for include virtual

I am building my site with a web deployment project but the build fails with a number of errors all relating to the "#include virtual" directives in my master page.
The includes are necessary to import a set of centrally managed html template files.
Here is an example of the include directive and associated error:
<!-- #include virtual="/v3/sits/pdpdev/assets-templates/inc/head.html" -->
/PDPRegistration.csproj/Pages/ContentPage.Master(15):
error ASPPARSE: Failed to map the path
'/v3/sits/pdpdev/assets-templates/inc/head.html'.
The error for each included file actually appears multiple times. I'm not sure what is being mapped or why, but this was never a problem until I started using WDP (which I wanted to alter web.config depending on the build environment, among other things.)
The project is built locally on my PC and then copied to the web server via a mapped drive. I found a few solutions on the 'net involving IIS metabase - they weren't quite clear to me, and I'm not sure if they apply given how I build and deploy the project (that is, would I have to build on the same system as IIS in order to make use of the metabase?)
Can anyone suggest how I can get my project to build with WDP?
Although SSI's are available within the Framework, the preferred way of doing include is to wrap the content from the file into a User Control (.ascx) as per the MSDN documentation See also: support.microsoft.com/kb/306575

Setting network options in a RCP Application

We have a RCP application that does sometimes get some data from URLs in the internet. Our customer uses a Proxy-Server, and we can't get to the information we need unless the network-settings are correct (Setting IP of Proxy and the Port-Number).
In Eclipse (the IDE), there is the Preferences->General->Network Connections Dialog to set those settings. I managed to include the Preferences Dialog( menu.add(new OpenPreferencesAction(window));, and even to get an option "Network Connections" (By adding a dependency to org.eclipse.ui.net in the plugin-settings.) But when I open the dialog, it says "The currently displayed page contains invalid values." and I can't set any values there.
the log files says: (thanks to VonC)
!ENTRY org.eclipse.jface 4 2 2009-11-09 21:51:39.798
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.jface".
!STACK 0
java.lang.NoClassDefFoundError: org/eclipse/core/internal/net/ProxySelector
at org.eclipse.ui.internal.net.ProxyEntriesComposite.initializeValues(ProxyEntriesComposite.java:248)
at org.eclipse.ui.internal.net.ProxyEntriesComposite.createWidgets(ProxyEntriesComposite.java:130)
at org.eclipse.ui.internal.net.ProxyEntriesComposite.(ProxyEntriesComposite.java:57)
at org.eclipse.ui.internal.net.ProxyPreferencePage.createProxyEntriesComposite(ProxyPreferencePage.java:81)
at org.eclipse.ui.internal.net.ProxyPreferencePage.createContents(ProxyPreferencePage.java:54)
at org.eclipse.jface.preference.PreferencePage.createControl(PreferencePage.java:235)
Does someone know a way to tell an eclipse-RCP application what network settings to use, either by using the preference page, by manual coding, or by using some configuration files?
Looks like I finally got it:
How to make setting the network configuration by the preference page possible in an RCP-Application in windows 32 bit:
Put the packages org.eclipse.ui.net, org.eclipse.core.net and org.eclipse.core.net.win32.x86 into your target plattform and add dependencies to the first two of these in your Manfifest.MF
Make sure you have compatible versions (That was my mistake, I had an old version of org.eclipse.net.win32.x86). For example, get the all three files from your Galileo Eclipse IDE
In your ActionBarAdvisor class, add: menu.add(new OpenPreferencesAction(getActionBarConfigurer().getWindowConfigurer()
.getWindow()));
Putting some DLL-files somewhere on the harddrive is not nessesary!
Howto use eclipse network options in your own plug-in (tested win32):
add jars: org.eclipse.core.net and org.eclipse.ui.net
add jWinHttp-1.0.0.dll (extraced from org.eclipse.core.net.win32.x86) to a directory
that is on the windows path (e.g. c:\windows).
Maybe it is also possible to pass a system property to search the dll at a specific location.
Now you can use the net api.

Resources