fixed attachment writing and added log4net