# importing logging in a custom filter

**URL:** https://discourse.paraview.org/t/importing-logging-in-a-custom-filter/3246
**Category:** Development
**Tags:** python
**Created:** [December 30, 2019, 10:36pm UTC](https://discourse.paraview.org/t/importing-logging-in-a-custom-filter/3246 "2019-12-30T22:36:29Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![majo\_vlas](https://discourse.paraview.org/user_avatar/discourse.paraview.org/majo_vlas/32/2567_2.png) [@majo\_vlas](https://discourse.paraview.org/u/majo_vlas)
#### Post date: [December 30, 2019, 10:36pm UTC](https://discourse.paraview.org/t/importing-logging-in-a-custom-filter/3246/1 "2019-12-30T22:36:29Z")

</div>

I have a custom filter and I have been trying to add logging, but can’t make it work, Paraview GUI keeps crashing and I have no idea why.

I have tried something like

```auto
import vtk
import math
import numpy as np
import numpy.linalg as la

from vtkmodules.util.vtkAlgorithm import VTKPythonAlgorithmBase
from vtkmodules.vtkCommonDataModel import vtkDataSet

from paraview.util.vtkAlgorithm import smproxy, smproperty

from vtk.numpy_interface import algorithms as algs
from vtk.numpy_interface import dataset_adapter as dsa
import logging

logging.basicConfig(filename='app.log', filemode='w', format='%(name)s - %(levelname)s - %(message)s')
logging.warning('This will get logged to a file')

@smproxy.filter(label="Custom Markers Filter")
@smproperty.input(name="Input")
class CustomMarkersFilter(VTKPythonAlgorithmBase):
    def __init__ (self):
        VTKPythonAlgorithmBase. __init__ (self)

    def RequestData(self, request, inInfo, outInfo):
        logging.info('Requesting Data')
        inp = vtkDataSet.GetData(inInfo[0])
        dsaInp = dsa.WrapDataObject(inp)

        points = dsaInp.GetPoints()

        centers = identify_markers(points)

        M1_, M2_, M3_ = centers
        print("M1': " + str(M1_))
        print("M2': " + str(M2_))
        print("M3': " + str(M3_))

        # Create vtkPoints from markers centers
        pts = vtk.vtkPoints()
        for p in centers:
            pts.InsertNextPoint(p)

        opt = vtkDataSet.GetData(outInfo)
        dsaOpt = dsa.WrapDataObject(opt)

        opt.SetPoints(pts)

        numPts = pts.GetNumberOfPoints()

        ptIds = vtk.vtkIdList()
        ptIds.SetNumberOfIds(numPts)
        for a in range(numPts):
            ptIds.SetId(a, a)

        dsaOpt.Allocate(1)
        dsaOpt.InsertNextCell(vtk.VTK_POLY_VERTEX, ptIds)

        return 1

```

I have also tried to initialize inside the class without success either.

Is there any way to get feedback even when the app crash?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [January 6, 2020, 11:02am UTC](https://discourse.paraview.org/t/importing-logging-in-a-custom-filter/3246/2 "2020-01-06T11:02:54Z")

</div>

Do you have an error message to share ?
