It needs a vent and a trap. You may not need to go all the way through the roof with it. If the sink nearby is properly vented, you can tie into that at least 42" above the floor (or 6" above the flood plane of the things that vent works on, whichever is higher) which is called a re-vent.
The thing to keep in mind is that when a line is a drain, it can no longer be used as a vent and vice versa. Dumping directly into a 4" pipe, you might get by without a vent, but it would not pass code, but if that 4" line is used as the drain for the upstairs baths, it should not be used as a vent for things below. Dumping it in below the traps of the nearby sink may just suck that trap dry when the WM runs without a proper vent.