Monday, April 14, 2008

Log4j Root Logger

I just found out that with log4j I can set-up a "root" logger. This is a catch-all logger that writes everything, regardless of the package. Seems pretty obvious, but I hadn't seen it before. If you use this in conjunction with a package logger, and you are outputting to the same file, then use the additivity="false" attribute on the package logger to stop lines appearing twice. My example log4j.xml file is below. Note that I output everything to stdout when developing, and then switch over to the rolling log file when I deploy it.


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="stdout" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<!-- Print the date in ISO 8601 format -->
<param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" />
</layout>
</appender>
<appender name="file" class="org.apache.log4j.RollingFileAppender">
<param name="file" value="/var/tmp/logs/myapp.log" />
<param name="MaxFileSize" value="10000KB" />
<param name="MaxBackupIndex" value="3" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" />
</layout>
</appender>
<logger name="org.apache.fop" additivity="false">
<level value="info" />
<appender-ref ref="stdout" />
</logger>
<logger name="com.example" additivity="false">
<level value="debug" />
<appender-ref ref="stdout" />
</logger>

<!-- root logger -->
<root>
<level value="info" />
<appender-ref ref="stdout" />
</root>
</log4j:configuration>


Friday, April 11, 2008

File Transfer between Machines using Remote Desktop over Cisco VPN

I access my work PC using Remote Desktop over a Cisco VPN. The VPN shuts down internet access on my PC while it is connected. I needed to get a large file from my work PC to my home PC over the VPN. For small files I'll use email with attachments but this doesn't work with bigger files due to size limits. The solution was to set-up a FTP Server on my home PC and use ftp from my work PC to put the file onto my home machine.

Setting up an FTP server on my home Windows XP machine was pretty straight-forward. It can be done through Add/Remove Programs, selecting Windows Components and then drilling down into IIS. Follow these steps here for more details. I set mine up with anonymous write access to keep it simple.

Once the ftp server was installed, I connected to my work PC went to the command prompt. The "ipconfig" command revealed the IP address of the VPN. It was then a matter of using "ftp" to connect to that IP address and put the file across. Use a login of "ftp" for anonymous access.

The only other thing to remember was to shutdown the ftp server (along with anonymous access privileges) at the end of it all. Don't want that running with anonymous write access all the time!

Thursday, April 10, 2008

Source Control under JumpBox

I've been doing .Net and VB6 development under Parallels on my Mac, and using Subversion mounted on a shared Parallels folder for source control (see this post). This gave me regular time machines backups...but the performance sucked! Checking at the trunk would take forever! And, of course, my Mac development work (Java, Cocoa, Grails etc) couldn't use the same repository.

So I've moved to Plan B - a Trac Jumpbox. This runs under Linux on Parallels and takes pretty much no set-up at all. You download it, fire it up and on the Trac home page you'll see the URL to use for Subversion access. I can now use this repository for both my Mac development and my Windows (parallels) development and it is all stored on the same machine. Plus I get the Trac source control viewer, diff tools etc which I've always loved (and a Wiki and bug management tool which I'm not going to use). It all runs right here on this machine, so I can do my dev work and check stuff in, without internet access.

There are a few hassles with this solution, so it might not be the final answer:

1. I need to remember to start-up the Trac Jumbox when I need source control. I could have it auto-start but I'm a big fan of a quick-starting machine. That's why I went to Mac in the first place! And I need to shut it down when I've finished.

2. When I'm doing Windows dev work I now have two virtual machines running. This performs fine as long as I don't sleep the machine. Waking it up is patchy at best and on several occasions I've had to reboot the Mac to get it working properly again. (Forget Fusion - I've tried it and I didn't like it!)

3. Time Machine doesn't back up virtual machines well (it backups the whole machine up every time), so it doesn't back my source control up. So I'm only backing up once a week via SuperDuper. This is not ideal!

4. This doesn't help me to develop on other machines in the house, or off-site. Should I be using a server, or perhaps hosted source control?

We'll see.

Monday, March 3, 2008

Remote Work and Communication

I've been working remotely, doing primarily development and architecture work, for the past 24 months. During this time I've used quite a few different communication mediums, each of which had their strengths and weaknesses.

Emails are the primary way of communicating. They are great for keeping track of what was said, clearly thinking out and stating a point, and useful for managing work.

Instant Messaging (IM) is very useful for a quick back and forth discussion: "how do you do X?", "can I checkout Y?", " I can't access Z, is it down?" Again, you have a full searchable history of what's been said which is very useful. If you find yourself chatting for more than 30 mins then you should probably have made a phone call. You also need to be careful not to slip into idle chatting which can be counter-productive (for both parties!). You can however, answer in your own time and you can flag yourself as busy if you don't want to be disturbed. Also, Skype client offers encryption which keeps everything safe.

Voice/Skype Sometimes a 3-day email back and forth could be easily solved by a 10 minute phone call, particularly something like talking though a business requirement with a BA. And it is good in the remote development world, to have a regular voice conference call/team catch-up. I used Skype because it is free, and free is good!

Collaborated Documents I have started using this with my "To Do" spreadsheet via Google Docs. It is not yet proving super-beneficial but I think that over time, once we adjust to think this way, it will offer a lot and save a lot of to-ing and fro-ing of document versions. I've used collaborated docs to good effect with bug lists.

Wikis These are super-useful. Typically have one per project. Source control, all project documentation, bug lists, project "how-tos" etc. People end up using it because they are just so darned easy to update! All those 1/2 to 2 pages documents end up being written in here. If your team are slack at documenting then try introducing a wiki! My only gripe (as a team member) is that it is not so easy to throw it on a flash drive and take it away with you when you leave.

Twitter Played with this for status updates but it didn't stick.

Thursday, February 28, 2008

Can't find your .Net dll in the VB6 Project References list?

I had created a new .Net Dll and done everything right, but couldn't for the life of me find the DLL in the VB6 references list. Everything looked fine in the registry with the HKEY_ROOT/CLSID and HKEY_ROOT/TYPELIB stuff there OK with the right Guids etc.

Normally you find it in the References list under the dll name eg. MyDll.dll would be called "MyDll" in the list. BUT, if you put a description in the .Net project file (Properties-Application-Assembly Information, the "Description" box), then that is the name that will appear in the References list, and also the name that will we shown under the Type Library list in the OLE View tool.

Moral of the story? Don't use the .Net Assembly Description field for COM compatible DLLs! Damn, that cost me hours!

Wednesday, February 27, 2008

Moving your svn repository to a Parallels Shared Network Drive on the Mac

I'm running svn under windows as a Windows Service on my Parallels virtual machine (not using Apache). I wanted to move the repository from my local c:\ drive to a shared Parallels folder to take advantage of TimeMachine backups of my svn repository. I ended up deleting and recreating the SVN service. These are the steps:

1. Find the service name. Look in the services console. Find the display name of the service in there. Then, from the command prompt, use the "sc query" command to list all of the services and find the matching display name.

2. Check the current config, especially the binary path to the snvserve exe.


C:\Documents and Settings\Administrator>sc query svnrepos
SERVICE_NAME: svnrepos
TYPE : 10 WIN32_OWN_PROCESS
STATE : 4 RUNNING
(STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0

C:\Documents and Settings\Administrator>sc qc svnrepos
[SC] GetServiceConfig SUCCESS
SERVICE_NAME: svnrepos
TYPE : 10 WIN32_OWN_PROCESS
START_TYPE : 2 AUTO_START
ERROR_CONTROL : 1 NORMAL
BINARY_PATH_NAME : "C:\program files\subversion\bin\svnserve.exe" --service -r "c:\svn"
LOAD_ORDER_GROUP :
TAG : 0
DISPLAY_NAME : Subversion Repository Local
DEPENDENCIES : Tcpip
SERVICE_START_NAME : LocalSystem


3. Delete the service.


sc stop svnrepos
sc delete svnrepos


4. Create the new service with the new file system path (don't forget the spaces after the '=' signs and the \ before the nested quotes). It is important to use the UNC path to the shared Parallels folder and not the drive letter, because the drive letter will not work! I found the UNC path by clicking "Map Network Drive" under explorer and looking in the drive dropdown. A quick test of "dir \\.psf\osxpshared" will tell if you got it right.

sc create svnrepos binpath= "\"c:\program files\subversion\bin\svnserve.exe\" --service -r \"\\.psf\osxpshared\svn\"" displayname= "Subversion Repository" depend= Tcpip start= auto

If you get the mysterious "service is marked for deletion" message then make sure you have closed the services console. This can keep a handle to the old service and stop it from being deleted.

5. Start the new service.

net start svnrepos


6. Check it works.

svn info svn://localhost

Thursday, February 21, 2008

How much can you change your WSDL before you need to recompile your .Net consumer?

If you have a .Net application that is consuming a web service, via a web reference, how much does the WSDL have to change before your compiled application will break? I set up a simple .Net web service and tried the following:


  • Added a new method. OK

  • Removed a method (not the one we are calling). OK.

  • Modified the method by changing the argument name. Method call still worked but no data was passed in.

  • Modified the method by adding an additional parameter. Method call still worked but new parameter was not set (obviously). Original parameter was still passed through.

  • Modified the method by removing a parameter. Method call still worked!

  • Modified the method changing the parameter type from string to int. Method FAILED with format error.

  • Modified the method changing the return type from string to int. Method call still worked.



Then I tried nested objects as parameters (we use these a bit):

  • Modified the method by changing the argument name of one of the nested objects parameters. Method call still worked but no data was passed in that parameter; all other params still populated.

  • Modified the nested object by adding an additional parameter. Method call still worked but new parameter was not set (obviously). Original parameters still passed through.

  • Modified the method by removing a parameter. Method call still worked!



So a web service call is pretty forgiving. We can change most of it without a recompilation being required.